include article thumbnail in opengraph image (where present)

This commit is contained in:
John Bowdre 2024-02-18 16:02:03 -06:00
parent 7d162f7295
commit 7529d0a664

View file

@ -23,16 +23,34 @@
<meta property="article:section" content="{{ .Section }}" /> <meta property="article:section" content="{{ .Section }}" />
{{ with .PublishDate }}<meta property="article:published_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }} {{ with .PublishDate }}<meta property="article:published_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }}
{{ with .Lastmod }}<meta property="article:modified_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }} {{ with .Lastmod }}<meta property="article:modified_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }}
{{ with .Params.thumbnail }}
{{/* $thumbPath := (add $.Page.RelPermalink . ) */}}
{{ $thumbnail := $.Resources.Get . }}
{{ with $thumbnail }}
{{ $img := $base.Filter (images.Overlay (.Process "fit 300x250") 875 38 )}}
{{ $img = $img.Filter (images.Text $.Page.Title (dict
"color" "#d8d8d8"
"size" 64
"linespacing" 2
"x" 40
"y" 300
"font" $font
))}}
{{ $img = resources.Copy (path.Join $.Page.RelPermalink "og.png") $img }}
{{ $.Scratch.Set "og_image" $img }}
{{ end }}
{{ else }}
{{ $img := $base.Filter (images.Text .Page.Title (dict {{ $img := $base.Filter (images.Text .Page.Title (dict
"color" "#d8d8d8" "color" "#d8d8d8"
"size" 64 "size" 64
"linespacing" 2 "linespacing" 2
"x" 40 "x" 40
"y" 240 "y" 300
"font" $font "font" $font
))}} ))}}
{{ $img = resources.Copy (path.Join .Page.RelPermalink "og.png") $img }} {{ $img = resources.Copy (path.Join $.Page.RelPermalink "og.png") $img }}
{{ .Scratch.Set "og_image" $img }} {{ .Scratch.Set "og_image" $img }}
{{ end }}
{{- end -}} {{- end -}}
{{ $img := .Scratch.Get "og_image" }} {{ $img := .Scratch.Get "og_image" }}