diff --git a/layouts/partials/opengraph.html b/layouts/partials/opengraph.html index dc5ed41..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,12 +15,15 @@ {{ with .PublishDate }}{{ end }} {{ with .Lastmod }}{{ end }} -{{ with .Params.thumbnail }} -{{/* $thumbPath := (add $.Page.RelPermalink . ) */}} +{{ $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 @@ -37,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" }}