theme: sync Hugo templates and unification #841 #845

- description
- title
- tags
This commit is contained in:
Sören Weber 2024-04-27 14:38:19 +02:00
parent aed8845a16
commit 64b4ad751e
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
15 changed files with 65 additions and 41 deletions

View file

@ -1,14 +1,20 @@
{{- partialCached "page-meta.hugo" . .RelPermalink }}
{{- $format := partial "get-format.hugo" . }}
{{- $outputFormat := partial "output-format.hugo" (dict "page" . "format" $format) }}
{{- $pages := slice }}
{{- range .Site.Pages }}
{{- if and .Title .RelPermalink (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSearchHiddenPages true) ) }}
{{- $tags := slice }}
{{- range .GetTerms "tags" }}
{{- $tags = $tags | append (partial "pageHelper/title.hugo" (dict "page" .Page "linkTitle" true "format" $format "outputFormat" $outputFormat) | plainify) }}
{{- end }}
{{- $pages = $pages | append (dict
"uri" (partial "relLangPrettyUglyURL.hugo" (dict "to" .))
"title" (partial "pageHelper/title.hugo" (dict "page" .))
"tags" .Params.tags
"breadcrumb" (trim ((partial "breadcrumbs.html" (dict "page" . "dirOnly" true)) | plainify | htmlUnescape) "\n\r\t ")
"description" (or .Description .Summary)
"content" (.Plain | htmlUnescape)
"title" (partial "pageHelper/title.hugo" (dict "page" . "format" $format "outputFormat" $outputFormat) | plainify)
"tags" $tags
"breadcrumb" (partial "breadcrumbs.html" (dict "page" . "dirOnly" true) | plainify | htmlUnescape | chomp)
"description" (or .Description .Summary | plainify | htmlUnescape | chomp)
"content" (.Plain | htmlUnescape | chomp)
) }}
{{- end }}
{{- end -}}

View file

@ -1,5 +1,7 @@
{{- /* based on Hugo 0.125.3 rss.xml */}}
{{- /* based on Hugo 0.125.5 rss.xml */}}
{{- partialCached "page-meta.hugo" . .RelPermalink }}
{{- $format := partial "get-format.hugo" . }}
{{- $outputFormat := partial "output-format.hugo" (dict "page" . "format" $format) }}
{{- /* Deprecate site.Author.email in favor of site.Params.author.email */}}
{{- $authorEmail := "" }}
{{- if and .Site.Params.author (reflect.IsMap .Site.Params.author) .Site.Params.author.email }}
@ -27,9 +29,9 @@
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }} on {{ end }}{{ .Site.Title }}{{ end }}</title>
<title>{{ partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true "format" $format "outputFormat" $outputFormat) }}</title>
<link>{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}</link>
<description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{ . }} {{ end }}{{ end }}on {{ .Site.Title }}</description>
<description>{{ or .Description .Summary | plainify | htmlUnescape | chomp | transform.XMLEscape | safeHTML }}</description>
<generator>Hugo</generator>
<language>{{ site.Language.LanguageCode }}</language>{{ with $authorEmail }}
<managingEditor>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with $authorEmail }}
@ -43,12 +45,12 @@
{{- $relearnIsHiddenFrom := index ($page.Scratch.Get "relearnIsHiddenFrom") .RelPermalink }}
{{- if and .Permalink .Title (or (not $relearnIsHiddenFrom) (ne .Site.Params.disableSeoHiddenPages true) ) }}
<item>
<title>{{ .Title }}</title>
<title>{{ partial "pageHelper/title.hugo" (dict "page" . "format" $format "outputFormat" $outputFormat) }}</title>
<link>{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}</link>
<pubDate>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{- with $authorEmail }}<author>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }}
<guid>{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}</guid>
<description>{{ .Summary | transform.XMLEscape | safeHTML }}</description>
<description>{{ or .Description .Summary | plainify | htmlUnescape | chomp | transform.XMLEscape | safeHTML }}</description>
</item>
{{- end }}
{{- end }}

View file

@ -1,4 +1,4 @@
{{- /* based on Hugo 0.125.3 sitemap.xml */}}
{{- /* based on Hugo 0.125.5 sitemap.xml */}}
{{- partialCached "page-meta.hugo" . .RelPermalink }}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>" | safeHTML }}
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">

View file

@ -22,7 +22,7 @@
{{- /* display pages of a term */}}
{{- $breadcrumb := "" }}
{{- if (ne .Page.Site.Params.disableTermBreadcrumbs true) }}
{{- $breadcrumb = (trim ((partial "breadcrumbs.html" (dict "page" .Page "dirOnly" true)) | plainify | htmlUnescape) "\n\r\t ") }}
{{- $breadcrumb = partial "breadcrumbs.html" (dict "page" .Page "dirOnly" true) | plainify | htmlUnescape | chomp }}
{{- end }}
<li><a href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" .Page) }}">{{ .Title }}</a>{{ with $breadcrumb }}<div class="breadcrumbs highlightable" title="{{ . }}">{{ . }}</div>{{ end }}</li>
{{- $lastCapital = $capital }}

View file

@ -1,4 +1,4 @@
{{- /* based on Hugo 0.125.3 alias.html */}}
{{- /* based on Hugo 0.125.5 alias.html */}}
<!DOCTYPE html>
<html>
<head>

View file

@ -13,7 +13,7 @@
{{- if not (and .Title (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSeoHiddenPages true) ) ) }}
<meta name="robots" content="noindex, nofollow, noarchive, noimageindex">
{{- end }}
<meta name="description" content="{{ with or .Description .Summary }}{{ . }}{{ end }}">
<meta name="description" content="{{ with or .Description .Summary | plainify | htmlUnescape | chomp }}{{ . }}{{ end }}">
{{- $authorName := partialCached "authorname.hugo" . }}
<meta name="author" content="{{ $authorName }}">
{{- partial "twitter_cards.html" . }}

View file

@ -1,4 +1,4 @@
{{- /* based on Hugo 0.125.3 opengraph.html */}}
{{- /* based on Hugo 0.125.5 opengraph.html */}}
{{- $format := partial "get-format.hugo" . }}
{{- $outputFormat := partial "output-format.hugo" (dict "page" . "format" $format) }}
{{- $basename := "index" }}
@ -7,12 +7,15 @@
{{- end }}
<meta property="og:url" content="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true "basename" $basename) }}">
{{- with or site.Title site.Params.title | plainify }}
{{- with site.Title | plainify }}
<meta property="og:site_name" content="{{ . }}">
{{- end }}
<meta property="og:title" content="{{ partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true "format" $format "outputFormat" $outputFormat) | plainify }}">
{{- with or .Description .Summary | plainify }}
{{- with partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true "format" $format "outputFormat" $outputFormat) | plainify }}
<meta property="og:title" content="{{ . }}">
{{- end }}
{{- with or .Description .Summary | plainify | htmlUnescape | chomp }}
<meta property="og:description" content="{{ . }}">
{{- end }}
@ -23,7 +26,7 @@
{{- if .IsPage }}
<meta property="og:type" content="article">
{{- with .FirstSection }}
<meta property="article:section" content="{{ partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true "format" $format "outputFormat" $outputFormat) | plainify }}">
<meta property="article:section" content="{{ partial "pageHelper/title.hugo" (dict "page" . "format" $format "outputFormat" $outputFormat) | plainify }}">
{{- end }}
{{- $iso8601 := "2006-01-02T15:04:05-07:00" }}
{{- with .PublishDate }}
@ -33,7 +36,7 @@
<meta property="article:modified_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }}>
{{- end }}
{{- range .GetTerms "tags" | first 6 }}
<meta property="article:tag" content="{{ .Page.Title | plainify }}">
<meta property="article:tag" content="{{ partial "pageHelper/title.hugo" (dict "page" .Page "linkTitle" true "format" $format "outputFormat" $outputFormat) | plainify }}">
{{- end }}
{{- else }}
<meta property="og:type" content="website">

View file

@ -1,3 +1,5 @@
{{- $format := partial "get-format.hugo" . }}
{{- $outputFormat := partial "output-format.hugo" (dict "page" . "format" $format) }}
{{- $pages := slice }}
{{- range .Data.Terms }}
{{- $count := 0 }}
@ -8,7 +10,7 @@
{{- end }}
{{- end }}
{{- if $count }}
{{- $pages = $pages| append (dict "Title" (default (humanize .Page.Data.Term | strings.Title) .Page.Title) "Page" .Page "Count" $count )}}
{{- $pages = $pages| append (dict "Title" (partial "pageHelper/title.hugo" (dict "page" .Page "linkTitle" true "format" $format "outputFormat" $outputFormat)) "Page" .Page "Count" $count )}}
{{- end }}
{{- end }}
{{- $pages = sort $pages ".Title" }}

View file

@ -5,6 +5,7 @@
{{- end }}
{{- $format := $.format | default (partial "get-format.hugo" .) }}
{{- $outputFormat := $.outputFormat | default (partial "output-format.hugo" (dict "page" . "format" $format)) }}
{{- $siteTitle := site.Title }}
{{- $title = .Title }}
{{- if $.linkTitle }}
{{- $title = or $.page.LinkTitle $title }}
@ -13,7 +14,7 @@
{{- if eq $outputFormat "searchpage" }}
{{- $title = T "Search" }}
{{- else if eq .Kind "home" }}
{{- $title = or $title site.Title }}
{{- $title = or $title $siteTitle }}
{{- else if eq .Kind "taxonomy" }}
{{- $title = default (default .Data.Plural (i18n .Data.Plural)) .Params.Title }}
{{- else if eq .Kind "term" }}
@ -30,11 +31,11 @@
{{- end }}
{{- if $.fullyQualified }}
{{- if and $title site.Title (not (eq $title site.Title)) }}
{{- if and $title $siteTitle (not (eq $title $siteTitle)) }}
{{- if $.reverse }}
{{- $title = printf "%s %s %s" $title (default "::" site.Params.titleSeparator) site.Title }}
{{- $title = printf "%s %s %s" $title (default "::" site.Params.titleSeparator) $siteTitle }}
{{- else }}
{{- $title = printf "%s %s %s" site.Title (default "::" site.Params.titleSeparator) $title }}
{{- $title = printf "%s %s %s" $siteTitle (default "::" site.Params.titleSeparator) $title }}
{{- end }}
{{- end }}
{{- end }}

View file

@ -1,9 +1,11 @@
{{- /* based on Hugo 0.125.3 schema.html */}}
{{- with partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true) }}
{{- /* based on Hugo 0.125.5 schema.html */}}
{{- $format := partial "get-format.hugo" . }}
{{- $outputFormat := partial "output-format.hugo" (dict "page" . "format" $format) }}
{{- with partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true "format" $format "outputFormat" $outputFormat) | plainify }}
<meta itemprop="name" content="{{ . }}">
{{- end }}
{{- with or .Description .Summary }}
{{- with or .Description .Summary | plainify | htmlUnescape | chomp }}
<meta itemprop="description" content="{{ . }}">
{{- end }}
@ -36,17 +38,17 @@ Keywords precedence:
*/}}
{{- $keywords := slice }}
{{- range .GetTerms "keywords" }}
{{- $keywords = $keywords | append .Title }}
{{- $keywords = $keywords | append (partial "pageHelper/title.hugo" (dict "page" .Page "linkTitle" true "format" $format "outputFormat" $outputFormat) | plainify) }}
{{- else }}
{{- with .Keywords }}
{{- $keywords = . }}
{{- else }}
{{- range .GetTerms "tags" }}
{{- $keywords = $keywords | append .Title }}
{{- $keywords = $keywords | append (partial "pageHelper/title.hugo" (dict "page" .Page "linkTitle" true "format" $format "outputFormat" $outputFormat) | plainify) }}
{{- else }}
{{- range $taxonomy, $_ := site.Taxonomies }}
{{- range $.GetTerms $taxonomy }}
{{- $keywords = $keywords | append .Title }}
{{- $keywords = $keywords | append (partial "pageHelper/title.hugo" (dict "page" .Page "linkTitle" true "format" $format "outputFormat" $outputFormat) | plainify) }}
{{- end }}
{{- end }}
{{- end }}

View file

@ -1,4 +1,4 @@
{{- /* based on Hugo 0.125.3 render-image.html */}}
{{- /* based on Hugo 0.125.5 render-image.html */}}
{{- $page := .page }}
{{- if and (not $page) .context }}
{{- $page = .context }}

View file

@ -1,4 +1,4 @@
{{- /* based on Hugo 0.125.3 render-link.html */}}
{{- /* based on Hugo 0.125.5 render-link.html */}}
{{- $page := .page }}
{{- if and (not $page) .context }}
{{- $page = .context }}

View file

@ -1,4 +1,6 @@
{{- $page := .page }}
{{- $format := partial "get-format.hugo" $page }}
{{- $outputFormat := partial "output-format.hugo" (dict "page" $page "format" $format) }}
{{- $taxonomy := .taxonomy }}
{{- $class := .class }}
{{- $color := .color | default "" }}
@ -18,7 +20,7 @@
{{- $term := . }}
{{- $term_key := $term }}
{{- with $page.Site.GetPage (printf "%s/%s" $taxonomy $term_key) }}
{{- $term_pages = $term_pages | append (dict "Title" (default (humanize .Data.Term | strings.Title) .Title) "Term" . )}}
{{- $term_pages = $term_pages | append (dict "Title" (partial "pageHelper/title.hugo" (dict "page" . "linkTitle" true "format" $format "outputFormat" $outputFormat)) "Term" . )}}
{{- else }}
{{- $term = trim $term " " }}
{{- if not $term }}
@ -26,16 +28,16 @@
{{- end }}
{{- $term_key = ($term | plainify | anchorize) }}
{{- with $page.Site.GetPage (printf "%s/%s" $taxonomy $term_key) }}
{{- $term_pages = $term_pages | append (dict "Title" (default (humanize .Data.Term | strings.Title) .Title) "Term" . )}}
{{- $term_pages = $term_pages | append (dict "Title" (partial "pageHelper/title.hugo" (dict "page" . "linkTitle" true "format" $format "outputFormat" $outputFormat)) "Term" . )}}
{{- else }}
{{- $term_key = ($term | urlize) }}
{{- with $page.Site.GetPage (printf "%s/%s" $taxonomy $term_key) }}
{{- $term_pages = $term_pages | append (dict "Title" (default (humanize .Data.Term | strings.Title) .Title) "Term" . )}}
{{- $term_pages = $term_pages | append (dict "Title" (partial "pageHelper/title.hugo" (dict "page" . "linkTitle" true "format" $format "outputFormat" $outputFormat)) "Term" . )}}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- $taxonomy_title := default (default $taxonomy_page.Data.Plural (i18n $taxonomy_page.Data.Plural)) $taxonomy_page.Params.Title }}
{{- $taxonomy_title := partial "pageHelper/title.hugo" (dict "page" $taxonomy_page "format" $format "outputFormat" $outputFormat) }}
{{- with $term_pages }}
<div class=" taxonomy-{{ $taxonomy }} term-list cstyle {{ $style }} {{ $class }}" title="{{ $taxonomy_title }}"{{ if $color }}{{ printf " style=\"--VARIABLE-TAGS-BG-color: %s;\"" $color | safeHTMLAttr }}{{ end }}>
{{- if $icon }}

View file

@ -9,7 +9,7 @@
{{- $currentDisableToc := .Params.disableToc | default $defaultDisableToc }}
{{- if and (eq $outputFormat "html") (not $currentDisableToc) }}
{{- $content := partial "toc-class.html" . }}
{{- $hascontent := not (eq 0 (int (len (trim ($content | plainify) "\n\r\t ")))) }}
{{- $hascontent := not (eq 0 (int (len ($content | plainify | chomp)))) }}
{{- if not $hascontent }}
{{- $content = " " }}
{{- end }}

View file

@ -1,4 +1,4 @@
{{- /* based on Hugo 0.125.3 twitter_cards.html */}}
{{- /* based on Hugo 0.125.5 twitter_cards.html */}}
{{- $images := partial "_funcs/get-page-images" . }}
{{- with index $images 0 }}
<meta name="twitter:card" content="summary_large_image">
@ -6,8 +6,14 @@
{{- else }}
<meta name="twitter:card" content="summary">
{{- end }}
<meta name="twitter:title" content="{{ partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true) }}">
<meta name="twitter:description" content="{{ with or .Description .Summary }}{{ . }}{{ end }}">
{{- with partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true) | plainify }}
<meta name="twitter:title" content="{{ . }}">
{{- end }}
{{- with or .Description .Summary | plainify | htmlUnescape | chomp }}
<meta name="twitter:description" content="{{ . }}">
{{- end }}
{{- $twitterSite := "" }}
{{- with site.Params.social }}