From c1a527a45468c00ca7cd27ee0a7c40a947210dd7 Mon Sep 17 00:00:00 2001 From: John Bowdre Date: Sun, 18 Feb 2024 19:27:36 -0600 Subject: [PATCH 1/2] remove unneeded comment --- layouts/partials/opengraph.html | 1 - 1 file changed, 1 deletion(-) diff --git a/layouts/partials/opengraph.html b/layouts/partials/opengraph.html index dc5ed41..2d5c966 100644 --- a/layouts/partials/opengraph.html +++ b/layouts/partials/opengraph.html @@ -24,7 +24,6 @@ {{ with .PublishDate }}{{ end }} {{ with .Lastmod }}{{ end }} {{ with .Params.thumbnail }} -{{/* $thumbPath := (add $.Page.RelPermalink . ) */}} {{ $thumbnail := $.Resources.Get . }} {{ with $thumbnail }} {{ $img := $base.Filter (images.Overlay (.Process "fit 300x250") 875 38 )}} From e9a40ec9f95e1a0b90383a98aead56d042cd5d0b Mon Sep 17 00:00:00 2001 From: John Bowdre Date: Sun, 18 Feb 2024 19:50:20 -0600 Subject: [PATCH 2/2] 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" }}