mirror of
https://github.com/nunocoracao/blowfish.git
synced 2026-01-30 15:31:52 +00:00
feat: support all types of sources for defaultSocialImage
This commit is contained in:
@@ -109,12 +109,25 @@
|
|||||||
{{ template "_internal/twitter_cards.html" . }}
|
{{ template "_internal/twitter_cards.html" . }}
|
||||||
{{- /* Main page always uses this; fallback elsewhere if no feature image */ -}}
|
{{- /* Main page always uses this; fallback elsewhere if no feature image */ -}}
|
||||||
{{- /* See https://gohugo.io/templates/embedded/#open-graph */ -}}
|
{{- /* See https://gohugo.io/templates/embedded/#open-graph */ -}}
|
||||||
{{ if not ($.Resources.GetMatch "*feature*") }}
|
|
||||||
{{ with .Site.Params.defaultSocialImage }}
|
{{- $images := .Resources.ByType "image" -}}
|
||||||
<meta name="twitter:image" content="{{ . | absURL }}" />
|
{{- $socialImage := $images.GetMatch "*feature*" -}}
|
||||||
<meta property="og:image" content="{{ . | absURL }}" />
|
|
||||||
{{ end }}
|
{{- if not $socialImage -}}
|
||||||
{{ end }}
|
{{- with .Site.Params.defaultSocialImage -}}
|
||||||
|
{{- if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") -}}
|
||||||
|
{{- $socialImage = resources.GetRemote . -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- $socialImage = resources.Get . -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- with $socialImage -}}
|
||||||
|
<meta name="twitter:image" content="{{ .RelPermalink | absURL }}" />
|
||||||
|
<meta property="og:image" content="{{ .RelPermalink | absURL }}" />
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
{{/* Schema */}}
|
{{/* Schema */}}
|
||||||
{{ partial "schema.html" . }}
|
{{ partial "schema.html" . }}
|
||||||
{{/* Me */}}
|
{{/* Me */}}
|
||||||
|
|||||||
Reference in New Issue
Block a user