include article thumbnail in opengraph image (where present)

This commit is contained in:
John Bowdre 2024-02-18 16:02:03 -06:00
parent 10e314e049
commit f174795a07

View file

@ -23,16 +23,34 @@
<meta property="article:section" content="{{ .Section }}" />
{{ 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 .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
"color" "#d8d8d8"
"size" 64
"linespacing" 2
"x" 40
"y" 240
"y" 300
"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 }}
{{ end }}
{{- end -}}
{{ $img := .Scratch.Get "og_image" }}