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 }}>
<generator uri="https://gohugo.io/" version="{{ hugo.Version }}">Hugo</generator>
{{- $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 `<title type="html"><![CDATA[%s]]></title>` $title | safeHTML }}
{{ with .Site.Params.subtitle }}
@ -37,7 +35,7 @@
{{- range $pages }}
{{ $page := . }}
<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 }} />
<id>{{ .Permalink }}</id>
{{ with .Params.authors -}}

View File

@ -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 }}",

View File

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

View File

@ -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 }}

View File

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

View File

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

View File

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