From 1b3e25abc326d03b2330cc2e6ec15bbbe2475447 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Sun, 6 Feb 2022 12:46:10 +0100 Subject: [PATCH] use title partial when possible (#190) --- layouts/_default/list.atom.xml | 8 +++----- layouts/_default/list.json.json | 8 +++----- layouts/partials/head/others.html | 14 +++++++++----- layouts/partials/head/schema.html | 4 ++-- layouts/partials/microformats/opengraph.html | 2 +- layouts/partials/microformats/twitter_cards.html | 2 +- layouts/partials/site-header.html | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/layouts/_default/list.atom.xml b/layouts/_default/list.atom.xml index a4187bc..01d79d7 100644 --- a/layouts/_default/list.atom.xml +++ b/layouts/_default/list.atom.xml @@ -2,10 +2,8 @@ Hugo {{- $title := .Site.Title -}} - {{- with .Title -}} - {{- if (not (eq . $title)) -}} - {{- $title = printf `%s on %s` . $title -}} - {{- end -}} + {{- if not (eq .Kind "home") -}} + {{- $title = printf `%s on %s` (partial "utils/title" .) $title -}} {{- end -}} {{ printf `<![CDATA[%s]]>` $title | safeHTML }} {{ with .Site.Params.subtitle }} @@ -37,7 +35,7 @@ {{- range $pages }} {{ $page := . }} - {{ printf `<![CDATA[%s]]>` .Title | safeHTML }} + {{ printf `<![CDATA[%s]]>` (partial "utils/title" .) | safeHTML }} {{ .Permalink }} {{ with .Params.authors -}} diff --git a/layouts/_default/list.json.json b/layouts/_default/list.json.json index af7bd50..af66370 100644 --- a/layouts/_default/list.json.json +++ b/layouts/_default/list.json.json @@ -1,8 +1,6 @@ {{- $title := .Site.Title -}} -{{- with .Title -}} - {{- if (not (eq . $title)) -}} - {{- $title = printf `%s on %s` . $title -}} - {{- end -}} +{{- if not (eq .Kind "home") -}} + {{- $title = printf `%s on %s` (partial "utils/title" .) $title -}} {{- end -}} { "version": "https://jsonfeed.org/version/1.1", @@ -33,7 +31,7 @@ {{- $len := (len $pages) }} {{- range $i, $page := $pages }} { - "title" : {{ .Title | jsonify }}, + "title" : {{ (partial "utils/title" .) | jsonify }}, "date_published" : {{ (.Date.Format "2006-01-02T15:04:05Z07:00") | jsonify }}, "date_modified" : {{ (.Lastmod.Format "2006-01-02T15:04:05Z07:00") | jsonify }}, "id" : "{{ .Permalink }}", diff --git a/layouts/partials/head/others.html b/layouts/partials/head/others.html index 4d86bd0..f411277 100644 --- a/layouts/partials/head/others.html +++ b/layouts/partials/head/others.html @@ -66,12 +66,16 @@ media="all" /> -{{ with .OutputFormats.Get "atom" }} - {{ printf `` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }} -{{ end }} +{{- with (.Site.GetPage "home").OutputFormats.Get "atom" }} + {{ printf `` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }} +{{- end }} -{{ if (default false $.Site.Params.GeekblogOverwriteHTMLBase) }} +{{- with (.Site.GetPage "home").OutputFormats.Get "json" }} + {{ printf `` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }} +{{- end }} + +{{- if (default false $.Site.Params.GeekblogOverwriteHTMLBase) }} -{{ end }} +{{- end }} {{ printf "" "Made with Geekblog theme https://github.com/thegeeklab/hugo-geekblog" | safeHTML }} diff --git a/layouts/partials/head/schema.html b/layouts/partials/head/schema.html index 1d4e0de..e2f4ff0 100644 --- a/layouts/partials/head/schema.html +++ b/layouts/partials/head/schema.html @@ -29,8 +29,8 @@ "@context": "http://schema.org", "@type": "BlogPosting", "articleSection": "{{ .Section }}", - "name": "{{ .Title | safeJS }}", - "headline": "{{ .Title | safeJS }}", + "name": "{{ (partial "utils/title" .) | safeJS }}", + "headline": "{{ (partial "utils/title" .) | safeJS }}", {{- with .Params.lead }} "alternativeHeadline": "{{ . }}", {{- end }} diff --git a/layouts/partials/microformats/opengraph.html b/layouts/partials/microformats/opengraph.html index 4af9f44..b763811 100644 --- a/layouts/partials/microformats/opengraph.html +++ b/layouts/partials/microformats/opengraph.html @@ -1,4 +1,4 @@ - + {{ with partial "utils/description" . }} {{ end }} diff --git a/layouts/partials/microformats/twitter_cards.html b/layouts/partials/microformats/twitter_cards.html index 035e877..aadd2ab 100644 --- a/layouts/partials/microformats/twitter_cards.html +++ b/layouts/partials/microformats/twitter_cards.html @@ -17,7 +17,7 @@ {{- end -}} {{- end -}} {{- end }} - + {{- with partial "utils/description" . }} {{- end }} diff --git a/layouts/partials/site-header.html b/layouts/partials/site-header.html index 008c01c..6066bcc 100644 --- a/layouts/partials/site-header.html +++ b/layouts/partials/site-header.html @@ -53,7 +53,7 @@ class="gblog-nav__entry {{ if eq $currentPage .RelPermalink }}is-active{{ end }}" href="{{ .RelPermalink }}" > - {{ .Title }} + {{ partial "utils/title" . }} {{ end }}