diff --git a/assets/FiraMono-Regular.ttf b/assets/FiraMono-Regular.ttf new file mode 100644 index 0000000..59e1e1a Binary files /dev/null and b/assets/FiraMono-Regular.ttf differ diff --git a/assets/og_base.png b/assets/og_base.png new file mode 100644 index 0000000..d535d82 Binary files /dev/null and b/assets/og_base.png differ diff --git a/layouts/partials/opengraph.html b/layouts/partials/opengraph.html index 3d2e916..f3263cf 100644 --- a/layouts/partials/opengraph.html +++ b/layouts/partials/opengraph.html @@ -1,98 +1,49 @@ -{{- $summary := truncate 160 .Summary }} -{{- $s := .Site.Params }} -{{- $p := .Params }} - -{{- $relpath := "" -}} -{{- if or $s.usePageBundles $p.usePageBundles }} - {{- $relpath = .Page.RelPermalink -}} -{{- end }} - -{{ if eq $p.usePageBundles false }} - {{- $relpath = "" }} -{{ end }} - -{{- with $p.description }} - {{- $summary = truncate 160 . }} -{{- end }} -{{- if .IsHome }} - {{- $summary = $s.description }} - {{- with $p.description }} - {{- $summary = . }} - {{- end }} -{{- end }} -{{- $site := .Site.Title }} -{{- $title := .Title }} -{{- $permalink := .Permalink }} -{{- $logo := absURL $s.logo }} -{{- $author := $s.author }} -{{- with $p.author }} - {{ $author := . }} -{{- end }} -{{- $image := absURL $s.fallBackOgImage }} -{{- with $p.featureImage }} - {{- $fullpath := ( add $relpath . ) -}} - {{- $image = absURL $fullpath }} -{{- end }} -{{- with $p.thumbnail }} - {{- $fullpath := ( add $relpath . ) -}} - {{- $image = absURL $fullpath }} -{{- end }} -{{- with $p.shareImage }} - {{- $fullpath := ( add $relpath . ) -}} - {{- $image = absURL $fullpath }} -{{- end }} + + + + {{- if .IsHome }} + {{- else }} {{- end }} - - - - - -{{- $keywords := "" }} -{{- with $s.keywords }} - {{- $keywords = delimit $s.keywords "," }} -{{- end }} -{{- with $p.keywords }} - {{- $keywords = delimit . "," }} -{{- end }} -{{- with $keywords }} - -{{- end }} -{{- if eq .Section $s.blogDir -}} - {{- $date := ( .Date.Format "2006-02-01") -}} - {{- $date := (time .Date) }} - {{- $lastMod := (time .Lastmod) }} - -{{- 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 + "linespacing" 2 + "x" 40 + "y" 240 + "font" $font +))}} +{{ $img = resources.Copy (path.Join .Page.RelPermalink "og.png") $img }} + + + + + + + + + +{{- end -}}