use title partial when possible (#190)

This commit is contained in:
Robert Kaussow 2022-02-06 12:46:10 +01:00 committed by GitHub
parent 91f44eb3a5
commit 1b3e25abc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 20 additions and 20 deletions

View File

@ -2,10 +2,8 @@
<feed xmlns="http://www.w3.org/2005/Atom"{{ with .Site.Language.Lang }} xml:lang="{{ . }}"{{ end }}> <feed xmlns="http://www.w3.org/2005/Atom"{{ with .Site.Language.Lang }} xml:lang="{{ . }}"{{ end }}>
<generator uri="https://gohugo.io/" version="{{ hugo.Version }}">Hugo</generator> <generator uri="https://gohugo.io/" version="{{ hugo.Version }}">Hugo</generator>
{{- $title := .Site.Title -}} {{- $title := .Site.Title -}}
{{- with .Title -}} {{- if not (eq .Kind "home") -}}
{{- if (not (eq . $title)) -}} {{- $title = printf `%s on %s` (partial "utils/title" .) $title -}}
{{- $title = printf `%s on %s` . $title -}}
{{- end -}}
{{- end -}} {{- end -}}
{{ printf `<title type="html"><![CDATA[%s]]></title>` $title | safeHTML }} {{ printf `<title type="html"><![CDATA[%s]]></title>` $title | safeHTML }}
{{ with .Site.Params.subtitle }} {{ with .Site.Params.subtitle }}
@ -37,7 +35,7 @@
{{- range $pages }} {{- range $pages }}
{{ $page := . }} {{ $page := . }}
<entry> <entry>
{{ printf `<title type="html"><![CDATA[%s]]></title>` .Title | safeHTML }} {{ printf `<title type="html"><![CDATA[%s]]></title>` (partial "utils/title" .) | safeHTML }}
<link href="{{ .Permalink }}?utm_source=atom_feed" rel="alternate" type="text/html" {{ with .Site.Language.Lang }} hreflang="{{ . }}"{{ end }} /> <link href="{{ .Permalink }}?utm_source=atom_feed" rel="alternate" type="text/html" {{ with .Site.Language.Lang }} hreflang="{{ . }}"{{ end }} />
<id>{{ .Permalink }}</id> <id>{{ .Permalink }}</id>
{{ with .Params.authors -}} {{ with .Params.authors -}}

View File

@ -1,8 +1,6 @@
{{- $title := .Site.Title -}} {{- $title := .Site.Title -}}
{{- with .Title -}} {{- if not (eq .Kind "home") -}}
{{- if (not (eq . $title)) -}} {{- $title = printf `%s on %s` (partial "utils/title" .) $title -}}
{{- $title = printf `%s on %s` . $title -}}
{{- end -}}
{{- end -}} {{- end -}}
{ {
"version": "https://jsonfeed.org/version/1.1", "version": "https://jsonfeed.org/version/1.1",
@ -33,7 +31,7 @@
{{- $len := (len $pages) }} {{- $len := (len $pages) }}
{{- range $i, $page := $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_published" : {{ (.Date.Format "2006-01-02T15:04:05Z07:00") | jsonify }},
"date_modified" : {{ (.Lastmod.Format "2006-01-02T15:04:05Z07:00") | jsonify }}, "date_modified" : {{ (.Lastmod.Format "2006-01-02T15:04:05Z07:00") | jsonify }},
"id" : "{{ .Permalink }}", "id" : "{{ .Permalink }}",

View File

@ -66,12 +66,16 @@
media="all" media="all"
/> />
{{ with .OutputFormats.Get "atom" }} {{- with (.Site.GetPage "home").OutputFormats.Get "atom" }}
{{ printf `<link rel="%s" type="%s" href="%s" title="%s">` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }} {{ printf `<link rel="%s" type="%s" href="%s" title="%s Atom Feed">` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
{{ end }} {{- end }}
{{ if (default false $.Site.Params.GeekblogOverwriteHTMLBase) }} {{- with (.Site.GetPage "home").OutputFormats.Get "json" }}
{{ printf `<link rel="%s" type="%s" href="%s" title="%s JSON Feed">` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
{{- end }}
{{- if (default false $.Site.Params.GeekblogOverwriteHTMLBase) }}
<base href="{{ .Site.BaseURL }}" /> <base href="{{ .Site.BaseURL }}" />
{{ end }} {{- end }}
{{ printf "<!-- %s -->" "Made with Geekblog theme https://github.com/thegeeklab/hugo-geekblog" | safeHTML }} {{ printf "<!-- %s -->" "Made with Geekblog theme https://github.com/thegeeklab/hugo-geekblog" | safeHTML }}

View File

@ -29,8 +29,8 @@
"@context": "http://schema.org", "@context": "http://schema.org",
"@type": "BlogPosting", "@type": "BlogPosting",
"articleSection": "{{ .Section }}", "articleSection": "{{ .Section }}",
"name": "{{ .Title | safeJS }}", "name": "{{ (partial "utils/title" .) | safeJS }}",
"headline": "{{ .Title | safeJS }}", "headline": "{{ (partial "utils/title" .) | safeJS }}",
{{- with .Params.lead }} {{- with .Params.lead }}
"alternativeHeadline": "{{ . }}", "alternativeHeadline": "{{ . }}",
{{- end }} {{- end }}

View File

@ -1,4 +1,4 @@
<meta property="og:title" content="{{ .Title }}" /> <meta property="og:title" content="{{ partial "utils/title" . }}" />
{{ with partial "utils/description" . }} {{ with partial "utils/description" . }}
<meta property="og:description" content="{{ trim (. | plainify) "\n" }}" /> <meta property="og:description" content="{{ trim (. | plainify) "\n" }}" />
{{ end }} {{ end }}

View File

@ -17,7 +17,7 @@
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- end }} {{- end }}
<meta name="twitter:title" content="{{ .Title }}" /> <meta name="twitter:title" content="{{ partial "utils/title" . }}" />
{{- with partial "utils/description" . }} {{- with partial "utils/description" . }}
<meta name="twitter:description" content="{{ trim (. | plainify) "\n" }}" /> <meta name="twitter:description" content="{{ trim (. | plainify) "\n" }}" />
{{- end }} {{- end }}

View File

@ -53,7 +53,7 @@
class="gblog-nav__entry {{ if eq $currentPage .RelPermalink }}is-active{{ end }}" class="gblog-nav__entry {{ if eq $currentPage .RelPermalink }}is-active{{ end }}"
href="{{ .RelPermalink }}" href="{{ .RelPermalink }}"
> >
{{ .Title }} {{ partial "utils/title" . }}
</a> </a>
</li> </li>
{{ end }} {{ end }}