From 74cfda7f254e3e4123403004580baf9fecc1f3ad Mon Sep 17 00:00:00 2001 From: John Bowdre Date: Fri, 16 Feb 2024 22:16:30 -0600 Subject: [PATCH] generate og:image for homepage too --- layouts/partials/opengraph.html | 37 +++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/layouts/partials/opengraph.html b/layouts/partials/opengraph.html index f3263cf..16a06b6 100644 --- a/layouts/partials/opengraph.html +++ b/layouts/partials/opengraph.html @@ -1,3 +1,5 @@ +{{ $base := resources.Get "og_base.png" }} +{{ $font := resources.Get "/FiraMono-Regular.ttf" }} @@ -5,29 +7,24 @@ {{- if .IsHome }} - -{{- else }} - +{{ $img := $base.Filter (images.Text .Site.Params.Description (dict + "color" "#d8d8d8" + "size" 64 + "linespacing" 2 + "x" 40 + "y" 300 + "font" $font +))}} +{{ $img = resources.Copy "og.png" $img }} + {{- end }} {{- if .IsPage }} + {{- $iso8601 := "2006-01-02T15:04:05-07:00" -}} {{ with .PublishDate }}{{ end }} {{ with .Lastmod }}{{ end }} -{{- end -}} - -{{- with .Params.audio }}{{ end }} -{{- with .Params.locale }}{{ end }} -{{- with .Site.Params.title }}{{ end }} -{{- with .Params.videos }}{{- range . }} - -{{ end }}{{ end }} - -{{- if .IsPage -}} -{{/* Generate opengraph image, based on https://aarol.dev/posts/hugo-og-image/ */}} -{{ $base := resources.Get "og_base.png" }} -{{ $font := resources.Get "/FiraMono-Regular.ttf"}} {{ $img := $base.Filter (images.Text .Page.Title (dict "color" "#d8d8d8" "size" 64 @@ -47,3 +44,11 @@ {{- end -}} + +{{- with .Params.audio }}{{ end }} +{{- with .Params.locale }}{{ end }} +{{- with .Site.Params.title }}{{ end }} +{{- with .Params.videos }}{{- range . }} + +{{ end }}{{ end }} +