From 179eda34500f3b714ba6baa3cf462c0c7820eeb1 Mon Sep 17 00:00:00 2001 From: BBaoVanC Date: Sat, 13 Nov 2021 19:37:50 -0600 Subject: [PATCH] Improve description wrapping in metadata --- layouts/partials/head.html | 4 ++-- layouts/partials/opengraph.html | 4 ++-- layouts/partials/schema.html | 26 ++++++++++++++++++++++++++ layouts/partials/twitter_cards.html | 25 +++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 layouts/partials/schema.html create mode 100644 layouts/partials/twitter_cards.html diff --git a/layouts/partials/head.html b/layouts/partials/head.html index dfc9ada..6f759f3 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -28,8 +28,8 @@ {{ end }} {{ partial "opengraph.html" . }} - {{ template "_internal/twitter_cards.html" . }} - {{ template "_internal/schema.html" . }} + {{ partial "twitter_cards.html" . }} + {{ partial "schema.html" . }} diff --git a/layouts/partials/opengraph.html b/layouts/partials/opengraph.html index 35c076e..d036161 100644 --- a/layouts/partials/opengraph.html +++ b/layouts/partials/opengraph.html @@ -1,6 +1,6 @@ - + - + diff --git a/layouts/partials/schema.html b/layouts/partials/schema.html new file mode 100644 index 0000000..fb55d95 --- /dev/null +++ b/layouts/partials/schema.html @@ -0,0 +1,26 @@ + + + + +{{- if .IsPage -}} +{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}} +{{ with .PublishDate }}{{ end}} +{{ with .Lastmod }}{{ end}} + + +{{- with $.Params.images -}} +{{- range first 6 . -}}{{ end -}} +{{- else -}} +{{- $images := $.Resources.ByType "image" -}} +{{- $featured := $images.GetMatch "*feature*" -}} +{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} +{{- with $featured -}} + +{{- else -}} +{{- with $.Site.Params.images -}}{{ end -}} +{{- end -}} +{{- end -}} + + + +{{- end -}} diff --git a/layouts/partials/twitter_cards.html b/layouts/partials/twitter_cards.html new file mode 100644 index 0000000..36bcca7 --- /dev/null +++ b/layouts/partials/twitter_cards.html @@ -0,0 +1,25 @@ + +{{- with $.Params.images -}} + + +{{ else -}} +{{- $images := $.Resources.ByType "image" -}} +{{- $featured := $images.GetMatch "*feature*" -}} +{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} +{{- with $featured -}} + + +{{- else -}} +{{- with $.Site.Params.images -}} + + +{{ else -}} + +{{- end -}} +{{- end -}} +{{- end }} + + +{{ with .Site.Social.twitter -}} + +{{ end -}}