title: avoid to much dependency on outputFormat #685

This commit is contained in:
Sören Weber 2024-07-22 00:15:38 +02:00
parent be860ccbf7
commit 926bea4727
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
11 changed files with 50 additions and 48 deletions

View file

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

View file

@ -1,7 +1,5 @@
{{- /* based on Hugo 0.125.5 rss.xml */}} {{- /* based on Hugo 0.125.5 rss.xml */}}
{{- partialCached "page-meta.hugo" . .RelPermalink }} {{- 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 */}} {{- /* Deprecate site.Author.email in favor of site.Params.author.email */}}
{{- $authorEmail := "" }} {{- $authorEmail := "" }}
{{- if and .Site.Params.author (reflect.IsMap .Site.Params.author) .Site.Params.author.email }} {{- if and .Site.Params.author (reflect.IsMap .Site.Params.author) .Site.Params.author.email }}
@ -29,7 +27,7 @@
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }} {{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel> <channel>
<title>{{ partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true "format" $format "outputFormat" $outputFormat) }}</title> <title>{{ partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true) }}</title>
<link>{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}</link> <link>{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}</link>
<description>{{ or .Description .Summary | plainify | htmlUnescape | chomp | transform.XMLEscape | safeHTML }}</description> <description>{{ or .Description .Summary | plainify | htmlUnescape | chomp | transform.XMLEscape | safeHTML }}</description>
<generator>Hugo</generator> <generator>Hugo</generator>
@ -51,7 +49,7 @@
{{- end }} {{- end }}
{{- if $visible }} {{- if $visible }}
<item> <item>
<title>{{ partial "pageHelper/title.hugo" (dict "page" . "format" $format "outputFormat" $outputFormat) }}</title> <title>{{ partial "pageHelper/title.hugo" (dict "page" .) }}</title>
<link>{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}</link> <link>{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}</link>
<pubDate>{{ (or .PublishDate .Date).Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate> <pubDate>{{ (or .PublishDate .Date).Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{- with $authorEmail }}<author>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }} {{- with $authorEmail }}<author>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }}

View file

@ -2,8 +2,10 @@
{{- $format := partial "get-format.hugo" . }} {{- $format := partial "get-format.hugo" . }}
{{- $outputFormat := partial "output-format.hugo" (dict "page" . "format" $format) }} {{- $outputFormat := partial "output-format.hugo" (dict "page" . "format" $format) }}
{{- $basename := "index" }} {{- $basename := "index" }}
{{- if eq $outputFormat "searchpage" }} {{- if eq .Kind "home" }}
{{- if eq $outputFormat "searchpage" }}
{{- $basename = partial "BaseName.hugo" $format.RelPermalink }} {{- $basename = partial "BaseName.hugo" $format.RelPermalink }}
{{- end }}
{{- end }} {{- end }}
{{- if eq . .Site.Sites.First.Home }} {{- if eq . .Site.Sites.First.Home }}
{{- $hugoVersion := "0.121.0" }} {{- $hugoVersion := "0.121.0" }}
@ -19,7 +21,7 @@
{{- partial "meta.html" . }} {{- partial "meta.html" . }}
{{- $page := . }} {{- $page := . }}
{{- $link := "<link href=\"%s\" rel=\"%s\" type=\"%s\" title=\"%s\">" }} {{- $link := "<link href=\"%s\" rel=\"%s\" type=\"%s\" title=\"%s\">" }}
{{- $title := partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true "format" $format "outputFormat" $outputFormat) }} {{- $title := partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true) }}
<title>{{ $title }}</title> <title>{{ $title }}</title>
{{- if .IsTranslated -}} {{- if .IsTranslated -}}

View file

@ -1,11 +1,13 @@
{{- $showvisitedlinks := .Site.Params.showVisitedLinks }} {{- $showvisitedlinks := .Site.Params.showVisitedLinks }}
{{- $basename := "index" }}
{{- if eq .Kind "home" }}
{{- $format := partial "get-format.hugo" . }} {{- $format := partial "get-format.hugo" . }}
{{- $outputFormat := partial "output-format.hugo" (dict "page" . "format" $format) }} {{- $outputFormat := partial "output-format.hugo" (dict "page" . "format" $format) }}
{{- $basename := "index" }}
{{- if eq $outputFormat "searchpage" }} {{- if eq $outputFormat "searchpage" }}
{{- $basename = partial "BaseName.hugo" $format.RelPermalink }} {{- $basename = partial "BaseName.hugo" $format.RelPermalink }}
{{- end }} {{- end }}
{{- end }}
<aside id="R-sidebar" class="default-animation{{ if $showvisitedlinks }} showVisitedLinks{{ end }}"> <aside id="R-sidebar" class="default-animation{{ if $showvisitedlinks }} showVisitedLinks{{ end }}">
{{- $currentNode := . }} {{- $currentNode := . }}
<div id="R-header-topbar" class="default-animation"></div> <div id="R-header-topbar" class="default-animation"></div>

View file

@ -1,9 +1,11 @@
{{- /* based on Hugo 0.125.5 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" }} {{- $basename := "index" }}
{{- if eq $outputFormat "searchpage" }} {{- if eq .Kind "home" }}
{{- $format := partial "get-format.hugo" . }}
{{- $outputFormat := partial "output-format.hugo" (dict "page" . "format" $format) }}
{{- if eq $outputFormat "searchpage" }}
{{- $basename = partial "BaseName.hugo" $format.RelPermalink }} {{- $basename = partial "BaseName.hugo" $format.RelPermalink }}
{{- end }}
{{- end }} {{- end }}
<meta property="og:url" content="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true "basename" $basename) }}"> <meta property="og:url" content="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true "basename" $basename) }}">
@ -11,7 +13,7 @@
<meta property="og:site_name" content="{{ . }}"> <meta property="og:site_name" content="{{ . }}">
{{- end }} {{- end }}
{{- with partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true "format" $format "outputFormat" $outputFormat) | plainify }} {{- with partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true) | plainify }}
<meta property="og:title" content="{{ . }}"> <meta property="og:title" content="{{ . }}">
{{- end }} {{- end }}
@ -26,7 +28,7 @@
{{- if .IsPage }} {{- if .IsPage }}
<meta property="og:type" content="article"> <meta property="og:type" content="article">
{{- with .FirstSection }} {{- with .FirstSection }}
<meta property="article:section" content="{{ partial "pageHelper/title.hugo" (dict "page" . "format" $format "outputFormat" $outputFormat) | plainify }}"> <meta property="article:section" content="{{ partial "pageHelper/title.hugo" (dict "page" .) | plainify }}">
{{- end }} {{- end }}
{{- $iso8601 := "2006-01-02T15:04:05-07:00" }} {{- $iso8601 := "2006-01-02T15:04:05-07:00" }}
{{- with or .PublishDate .Date }} {{- with or .PublishDate .Date }}
@ -36,7 +38,7 @@
<meta property="article:modified_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }}> <meta property="article:modified_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }}>
{{- end }} {{- end }}
{{- range .GetTerms "tags" | first 6 }} {{- range .GetTerms "tags" | first 6 }}
<meta property="article:tag" content="{{ partial "pageHelper/title.hugo" (dict "page" .Page "linkTitle" true "format" $format "outputFormat" $outputFormat) | plainify }}"> <meta property="article:tag" content="{{ partial "pageHelper/title.hugo" (dict "page" .Page "linkTitle" true) | plainify }}">
{{- end }} {{- end }}
{{- else }} {{- else }}
<meta property="og:type" content="website"> <meta property="og:type" content="website">

View file

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

View file

@ -11,8 +11,11 @@
{{- if eq .Kind "home" }} {{- if eq .Kind "home" }}
{{- $title = $title | default $siteTitle }} {{- $title = $title | default $siteTitle }}
{{- $outputFormat := $.outputFormat }}
{{- if not $outputFormat }}
{{- $format := $.format | default (partial "get-format.hugo" .) }} {{- $format := $.format | default (partial "get-format.hugo" .) }}
{{- $outputFormat := $.outputFormat | default (partial "output-format.hugo" (dict "page" . "format" $format)) }} {{- $outputFormat = $.outputFormat | default (partial "output-format.hugo" (dict "page" . "format" $format)) }}
{{- end }}
{{- if eq $outputFormat "searchpage" }} {{- if eq $outputFormat "searchpage" }}
{{- $title = T "Search" }} {{- $title = T "Search" }}
{{- end }} {{- end }}

View file

@ -1,7 +1,5 @@
{{- /* based on Hugo 0.125.5 schema.html */}} {{- /* based on Hugo 0.125.5 schema.html */}}
{{- $format := partial "get-format.hugo" . }} {{- with partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true) | plainify }}
{{- $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="{{ . }}"> <meta itemprop="name" content="{{ . }}">
{{- end }} {{- end }}
@ -38,17 +36,17 @@ Keywords precedence:
*/}} */}}
{{- $keywords := slice }} {{- $keywords := slice }}
{{- range .GetTerms "keywords" }} {{- range .GetTerms "keywords" }}
{{- $keywords = $keywords | append (partial "pageHelper/title.hugo" (dict "page" .Page "linkTitle" true "format" $format "outputFormat" $outputFormat) | plainify) }} {{- $keywords = $keywords | append (partial "pageHelper/title.hugo" (dict "page" .Page "linkTitle" true) | plainify) }}
{{- else }} {{- else }}
{{- with .Keywords }} {{- with .Keywords }}
{{- $keywords = . }} {{- $keywords = . }}
{{- else }} {{- else }}
{{- range .GetTerms "tags" }} {{- range .GetTerms "tags" }}
{{- $keywords = $keywords | append (partial "pageHelper/title.hugo" (dict "page" .Page "linkTitle" true "format" $format "outputFormat" $outputFormat) | plainify) }} {{- $keywords = $keywords | append (partial "pageHelper/title.hugo" (dict "page" .Page "linkTitle" true) | plainify) }}
{{- else }} {{- else }}
{{- range $taxonomy, $_ := site.Taxonomies }} {{- range $taxonomy, $_ := site.Taxonomies }}
{{- range $.GetTerms $taxonomy }} {{- range $.GetTerms $taxonomy }}
{{- $keywords = $keywords | append (partial "pageHelper/title.hugo" (dict "page" .Page "linkTitle" true "format" $format "outputFormat" $outputFormat) | plainify) }} {{- $keywords = $keywords | append (partial "pageHelper/title.hugo" (dict "page" .Page "linkTitle" true) | plainify) }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- end }} {{- end }}

View file

@ -1,6 +1,4 @@
{{- $page := .page }} {{- $page := .page }}
{{- $format := partial "get-format.hugo" $page }}
{{- $outputFormat := partial "output-format.hugo" (dict "page" $page "format" $format) }}
{{- $taxonomy := .taxonomy }} {{- $taxonomy := .taxonomy }}
{{- $class := .class }} {{- $class := .class }}
{{- $color := .color | default "" }} {{- $color := .color | default "" }}
@ -16,9 +14,9 @@
{{- $taxonomy_page := $page.Site.GetPage $taxonomy }} {{- $taxonomy_page := $page.Site.GetPage $taxonomy }}
{{- $term_pages := slice }} {{- $term_pages := slice }}
{{- range $page.GetTerms $taxonomy }} {{- range $page.GetTerms $taxonomy }}
{{- $term_pages = $term_pages | append (dict "Title" (partial "pageHelper/title.hugo" (dict "page" . "linkTitle" true "format" $format "outputFormat" $outputFormat)) "Term" . )}} {{- $term_pages = $term_pages | append (dict "Title" (partial "pageHelper/title.hugo" (dict "page" . "linkTitle" true)) "Term" . )}}
{{- end }} {{- end }}
{{- $taxonomy_title := partial "pageHelper/title.hugo" (dict "page" $taxonomy_page "format" $format "outputFormat" $outputFormat) }} {{- $taxonomy_title := partial "pageHelper/title.hugo" (dict "page" $taxonomy_page) }}
{{- with $term_pages }} {{- 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 }}> <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 }} {{- if $icon }}

View file

@ -2,8 +2,6 @@
{{- $onwidthm := cond (isset . "onwidthm") .onwidthm "show" }} {{- $onwidthm := cond (isset . "onwidthm") .onwidthm "show" }}
{{- $onwidthl := cond (isset . "onwidthl") .onwidthl "show" }} {{- $onwidthl := cond (isset . "onwidthl") .onwidthl "show" }}
{{- with .page }} {{- with .page }}
{{- $format := partial "get-format.hugo" . }}
{{- $outputFormat := partial "output-format.hugo" (dict "page" . "format" $format) }}
{{- $showPrevNext := (and (not .Params.disableNextPrev) (not .Site.Params.disableNextPrev)) }} {{- $showPrevNext := (and (not .Params.disableNextPrev) (not .Site.Params.disableNextPrev)) }}
{{- if $showPrevNext }} {{- if $showPrevNext }}
{{- $endarrow := "🡒" }} {{- $endarrow := "🡒" }}
@ -11,8 +9,12 @@
{{- $endarrow = "🡐" }} {{- $endarrow = "🡐" }}
{{- end }} {{- end }}
{{- $next := .Scratch.Get "relearnNextPage" }} {{- $next := .Scratch.Get "relearnNextPage" }}
{{- if eq .Page.Kind "home" }}
{{- $format := partial "get-format.hugo" .Page }}
{{- $outputFormat := partial "output-format.hugo" (dict "page" .Page "format" $format) }}
{{- if eq $outputFormat "searchpage" }} {{- if eq $outputFormat "searchpage" }}
{{- $next = "" }} {{- $next = "" }}
{{- end }}
{{- else if eq .Page.Kind "term" }} {{- else if eq .Page.Kind "term" }}
{{- /* go to next term page */}} {{- /* go to next term page */}}
{{- $taxonomy_page := .Site.GetPage .Data.Plural }} {{- $taxonomy_page := .Site.GetPage .Data.Plural }}
@ -23,7 +25,7 @@
{{- $pages := partialCached "partials/pageHelper/taxonomyPages.html" . . }} {{- $pages := partialCached "partials/pageHelper/taxonomyPages.html" . . }}
{{- $next = (index $pages 0).Page }} {{- $next = (index $pages 0).Page }}
{{- end }} {{- end }}
{{- $nextTitle := partial "pageHelper/title.hugo" (dict "page" $next "format" $format "outputFormat" $outputFormat) }} {{- $nextTitle := partial "pageHelper/title.hugo" (dict "page" $next "outputFormat" "html") }}
{{- partial "topbar/func/button.html" (dict {{- partial "topbar/func/button.html" (dict
"page" . "page" .
"class" "topbar-button-next" "class" "topbar-button-next"

View file

@ -2,8 +2,6 @@
{{- $onwidthm := cond (isset . "onwidthm") .onwidthm "show" }} {{- $onwidthm := cond (isset . "onwidthm") .onwidthm "show" }}
{{- $onwidthl := cond (isset . "onwidthl") .onwidthl "show" }} {{- $onwidthl := cond (isset . "onwidthl") .onwidthl "show" }}
{{- with .page }} {{- with .page }}
{{- $format := partial "get-format.hugo" . }}
{{- $outputFormat := partial "output-format.hugo" (dict "page" . "format" $format) }}
{{- $showPrevNext := (and (not .Params.disableNextPrev) (not .Site.Params.disableNextPrev)) }} {{- $showPrevNext := (and (not .Params.disableNextPrev) (not .Site.Params.disableNextPrev)) }}
{{- if $showPrevNext }} {{- if $showPrevNext }}
{{- $startarrow := "🡐" }} {{- $startarrow := "🡐" }}
@ -11,9 +9,12 @@
{{- $startarrow = "🡒" }} {{- $startarrow = "🡒" }}
{{- end }} {{- end }}
{{- $prev := .Scratch.Get "relearnPrevPage" }} {{- $prev := .Scratch.Get "relearnPrevPage" }}
{{- if eq .Page.Kind "home" }}
{{- $format := partial "get-format.hugo" .Page }}
{{- $outputFormat := partial "output-format.hugo" (dict "page" .Page "format" $format) }}
{{- if eq $outputFormat "searchpage" }} {{- if eq $outputFormat "searchpage" }}
{{- $outputFormat = "html" }}
{{- $prev = .Site.Home }} {{- $prev = .Site.Home }}
{{- end }}
{{- else if eq .Page.Kind "term" }} {{- else if eq .Page.Kind "term" }}
{{- /* go to previous term page or taxonomy page if it is the first term */}} {{- /* go to previous term page or taxonomy page if it is the first term */}}
{{- $taxonomy_page := .Site.GetPage .Data.Plural }} {{- $taxonomy_page := .Site.GetPage .Data.Plural }}
@ -22,7 +23,7 @@
{{- else if eq .Page.Kind "taxonomy" }} {{- else if eq .Page.Kind "taxonomy" }}
{{- $prev = .Site.Home }} {{- $prev = .Site.Home }}
{{- end }} {{- end }}
{{- $prevTitle := partial "pageHelper/title.hugo" (dict "page" $prev "format" $format "outputFormat" $outputFormat) }} {{- $prevTitle := partial "pageHelper/title.hugo" (dict "page" $prev "outputFormat" "html") }}
{{- partial "topbar/func/button.html" (dict {{- partial "topbar/func/button.html" (dict
"page" . "page" .
"class" "topbar-button-prev" "class" "topbar-button-prev"