From 55c8934ebcb251db652bc8937e2b5ad8ff0f3d16 Mon Sep 17 00:00:00 2001 From: John Bowdre Date: Sun, 18 Feb 2024 19:50:20 -0600 Subject: [PATCH] opengraph efficiency++ --- layouts/partials/opengraph.html | 40 +++++++++------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/layouts/partials/opengraph.html b/layouts/partials/opengraph.html index 2d5c966..eba61bd 100644 --- a/layouts/partials/opengraph.html +++ b/layouts/partials/opengraph.html @@ -1,21 +1,13 @@ -{{ $base := resources.Get "og_base.png" }} +{{ $img := resources.Get "og_base.png" }} {{ $font := resources.Get "/FiraMono-Regular.ttf" }} +{{ $text := "" }} {{- if .IsHome }} -{{ $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 }} -{{ .Scratch.Set "og_image" $img }} +{{ $text = .Site.Params.Description }} {{- end }} {{- if .IsPage }} @@ -23,11 +15,15 @@ {{ with .PublishDate }}{{ end }} {{ with .Lastmod }}{{ end }} -{{ with .Params.thumbnail }} +{{ $text = .Page.Title }} +{{ end }} + +{{- with .Params.thumbnail }} {{ $thumbnail := $.Resources.Get . }} {{ with $thumbnail }} -{{ $img := $base.Filter (images.Overlay (.Process "fit 300x250") 875 38 )}} -{{ $img = $img.Filter (images.Text $.Page.Title (dict +{{ $img = $img.Filter (images.Overlay (.Process "fit 300x250") 875 38 )}} +{{ end }}{{ end }} +{{ $img = $img.Filter (images.Text $text (dict "color" "#d8d8d8" "size" 64 "linespacing" 2 @@ -36,22 +32,6 @@ "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" 300 - "font" $font -))}} -{{ $img = resources.Copy (path.Join $.Page.RelPermalink "og.png") $img }} -{{ .Scratch.Set "og_image" $img }} -{{ end }} -{{- end -}} -{{ $img := .Scratch.Get "og_image" }}