From 91f44eb3a534022190b61093c4cb6cba8b37e2ca Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Sat, 5 Feb 2022 20:02:17 +0100 Subject: [PATCH] refactor: unify title and description handling in meta files (#189) --- layouts/_default/baseof.html | 8 +- layouts/_default/list.atom.xml | 4 +- layouts/_default/list.html | 4 +- layouts/_default/single.html | 7 +- layouts/_default/taxonomy.html | 4 +- layouts/partials/head/meta.html | 5 +- layouts/partials/head/schema.html | 174 +++++++++--------- layouts/partials/microformats/opengraph.html | 15 +- .../partials/microformats/twitter_cards.html | 19 +- layouts/partials/utils/description.html | 13 ++ layouts/partials/{ => utils}/title.html | 0 11 files changed, 127 insertions(+), 126 deletions(-) create mode 100644 layouts/partials/utils/description.html rename layouts/partials/{ => utils}/title.html (100%) diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 99e22e8..c2761c1 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -8,9 +8,11 @@ {{ partial "head/meta" . }} - {{ if not (eq .Kind "home") }} - {{ partial "title" . }}{{ printf " | " }} - {{ end }}{{ .Site.Title }} + {{- if eq .Kind "home" -}} + {{ .Site.Title }} + {{- else -}} + {{ printf "%s | %s" (partial "utils/title" .) .Site.Title }} + {{- end -}} {{ partial "head/favicons" . }} diff --git a/layouts/_default/list.atom.xml b/layouts/_default/list.atom.xml index 128dc36..a4187bc 100644 --- a/layouts/_default/list.atom.xml +++ b/layouts/_default/list.atom.xml @@ -50,9 +50,7 @@ {{- end }} {{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }} {{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }} - {{ $desc := .Description | default "" }} - {{ $description := (cond (eq "" $desc) "" (printf "
%s
" ($desc | $.Page.RenderString))) }} - {{ printf `` $description .Content | safeHTML }} + {{ printf `` .Content | safeHTML }} {{ with .Site.Taxonomies }} {{ range $taxo,$_ := . }} {{ with $page.Param $taxo }} diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 61ff6ed..a228991 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -9,12 +9,12 @@

- {{ partial "title" . }} + {{ partial "utils/title" . }}

- {{ .Summary }} + {{ partial "utils/description" . }}
{{ if .Truncated }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 08090b1..5425701 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -7,7 +7,10 @@ {{ $featured := .Fill (printf "910x280 %s" (default "Smart" .Params.anchor)) }} - {{ default $.Title .Params.description }} + {{ default (partial {{ with $source.Params.credits }} Credits: {{ . | $.Page.RenderString | safeHTML }} @@ -16,7 +19,7 @@ {{ end }} -

{{ partial "title" . }}

+

{{ partial "utils/title" . }}

{{ if or (eq .Type (default "posts" .Site.Params.GeekblogContentSection)) (eq .Type "post") }}