theme: dry out title generation #825

This commit is contained in:
Sören Weber 2024-04-07 21:41:06 +02:00
parent 36e6ccdf5b
commit 24c7258eb4
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
17 changed files with 89 additions and 156 deletions

View file

@ -4,13 +4,7 @@
<html lang="{{ .Page.Language.LanguageCode | default "en" }}" dir="{{ .Page.Language.LanguageDirection | default (T "Reading-direction") | default "ltr" }}"> <html lang="{{ .Page.Language.LanguageCode | default "en" }}" dir="{{ .Page.Language.LanguageDirection | default (T "Reading-direction") | default "ltr" }}">
<head> <head>
{{- partial "meta.html" . }} {{- partial "meta.html" . }}
{{- $title := .Title }} {{- $title := partial "pageHelper/fullTitle.hugo" (dict "page" . "invert" true) }}
{{- if eq .Site.Data.titles .Title }}
{{- $title = (index .Site.Data.titles .Title).title }}
{{- end }}
{{- if and $title .Site.Title (not (eq $title .Site.Title)) }}
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) .Site.Title }}
{{- end }}
<title>{{ $title }}</title> <title>{{ $title }}</title>
<base href="{{ .Site.BaseURL }}"> <base href="{{ .Site.BaseURL }}">
{{- partialCached "favicon.html" . }} {{- partialCached "favicon.html" . }}

View file

@ -2,17 +2,9 @@
{{- $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) ) }}
{{- $title := .Title }}
{{- if eq .Kind "taxonomy" }}
{{- $title = default (default .Data.Plural (i18n .Data.Plural)) .Params.Title }}
{{- else if eq .Kind "term" }}
{{- $taxonomy_page := .Site.GetPage .Data.Plural }}
{{- $title = default (default .Data.Singular (i18n .Data.Singular)) $taxonomy_page.Params.SingularTitle }}
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) (default (humanize .Data.Term | strings.Title) .Title) }}
{{- end }}
{{- $pages = $pages | append (dict {{- $pages = $pages | append (dict
"uri" (partial "relLangPrettyUglyURL.hugo" (dict "to" .)) "uri" (partial "relLangPrettyUglyURL.hugo" (dict "to" .))
"title" $title "title" (partial "pageHelper/title.hugo" (dict "page" .))
"tags" .Params.tags "tags" .Params.tags
"breadcrumb" (trim ((partial "breadcrumbs.html" (dict "page" . "dirOnly" true)) | plainify | htmlUnescape) "\n\r\t ") "breadcrumb" (trim ((partial "breadcrumbs.html" (dict "page" . "dirOnly" true)) | plainify | htmlUnescape) "\n\r\t ")
"description" .Description "description" .Description

View file

@ -2,17 +2,9 @@
{{- $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) ) }}
{{- $title := .Title }}
{{- if eq .Kind "taxonomy" }}
{{- $title = default (default .Data.Plural (i18n .Data.Plural)) .Params.Title }}
{{- else if eq .Kind "term" }}
{{- $taxonomy_page := .Site.GetPage .Data.Plural }}
{{- $title = default (default .Data.Singular (i18n .Data.Singular)) $taxonomy_page.Params.SingularTitle }}
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) (default (humanize .Data.Term | strings.Title) .Title) }}
{{- end }}
{{- $pages = $pages | append (dict {{- $pages = $pages | append (dict
"uri" (partial "relLangPrettyUglyURL.hugo" (dict "to" .)) "uri" (partial "relLangPrettyUglyURL.hugo" (dict "to" .))
"title" $title "title" (partial "pageHelper/title.hugo" (dict "page" .))
"tags" .Params.tags "tags" .Params.tags
"breadcrumb" (trim ((partial "breadcrumbs.html" (dict "page" . "dirOnly" true)) | plainify | htmlUnescape) "\n\r\t ") "breadcrumb" (trim ((partial "breadcrumbs.html" (dict "page" . "dirOnly" true)) | plainify | htmlUnescape) "\n\r\t ")
"description" .Description "description" .Description

View file

@ -5,7 +5,7 @@
</header> </header>
{{- $page := . }} {{- $page := . }}
{{- $title := default (default .Data.Plural (i18n .Data.Plural)) .Params.Title }} {{- $title := partial "pageHelper/title.hugo" (dict "page" .) }}
<h1 id="{{ $title | plainify | anchorize }}">{{ $title }}</h1> <h1 id="{{ $title | plainify | anchorize }}">{{ $title }}</h1>
{{- .Content }} {{- .Content }}
{{- $lastCapital := "" }} {{- $lastCapital := "" }}

View file

@ -5,9 +5,7 @@
</header> </header>
{{- $page := . }} {{- $page := . }}
{{- $taxonomy_page := .Site.GetPage .Data.Plural }} {{- $title := partial "pageHelper/title.hugo" (dict "page" .) }}
{{- $title := default (default .Data.Singular (i18n .Data.Singular)) $taxonomy_page.Params.SingularTitle }}
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) (default (humanize .Data.Term | strings.Title) .Title) }}
<h1 id="{{ $title | plainify | anchorize }}">{{ $title }}</h1> <h1 id="{{ $title | plainify | anchorize }}">{{ $title }}</h1>
{{- .Content }} {{- .Content }}
{{- $lastCapital := "" }} {{- $lastCapital := "" }}

View file

@ -1,5 +1,5 @@
{{- $page := .page }} {{- $page := .page }}
{{- $title := T "Search" }} {{- $title := partial "pageHelper/title.hugo" (dict "page" .page) }}
<article class="default"> <article class="default">
<header class="headline"> <header class="headline">
</header> </header>

View file

@ -31,17 +31,7 @@
{{- range $i, $e := $breadcrumbReversed }} {{- range $i, $e := $breadcrumbReversed }}
{{- $to := $e }} {{- $to := $e }}
{{- $depth = add $depth 1 }} {{- $depth = add $depth 1 }}
{{- $title := or $to.Params.menuTitle $to.LinkTitle $to.Title }} {{- $title := partial "pageHelper/title.hugo" (dict "page" $to "useLinkTitle" true) }}
{{- if eq $to.Kind "taxonomy" }}
{{- $title = default (default $to.Data.Plural (i18n $to.Data.Plural)) $to.Params.Title }}
{{- else if eq $to.Kind "term" }}
{{- $taxonomy_page := $to.Site.GetPage $to.Data.Plural }}
{{- $title = default (default $to.Data.Singular (i18n $to.Data.Singular)) $taxonomy_page.Params.SingularTitle }}
{{- $title = printf "%s %s %s" $title (default "::" $to.Site.Params.titleSeparator) (default (humanize $to.Data.Term | strings.Title) $to.Title) }}
{{- end }}
{{- if not $title }}
{{- $title = $to.Site.Title }}
{{- end }}
{{- $url := partial "relLangPrettyUglyURL.hugo" (dict "to" $to) }} {{- $url := partial "relLangPrettyUglyURL.hugo" (dict "to" $to) }}
{{- $isPage := eq $url $pageurl }} {{- $isPage := eq $url $pageurl }}
{{- $isLast := eq $url $lasturl }} {{- $isLast := eq $url $lasturl }}

View file

@ -16,22 +16,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 := .Title }} {{- $title := partial "pageHelper/fullTitle.hugo" (dict "page" . "invert" true "format" $format "outputFormat" $outputFormat) }}
{{- if eq $outputFormat "searchpage" }}
{{- $title = T "Search" }}
{{- else if eq .Kind "taxonomy" }}
{{- $title = default (default .Data.Plural (i18n .Data.Plural)) .Params.Title }}
{{- else if eq .Kind "term" }}
{{- $taxonomy_page := .Site.GetPage .Data.Plural }}
{{- $title = default (default .Data.Singular (i18n .Data.Singular)) $taxonomy_page.Params.SingularTitle }}
{{- $title = printf "%s %s %s" (default (humanize .Data.Term | strings.Title) .Title) (default "::" .Site.Params.titleSeparator) $title }}
{{- end }}
{{- if and $title .Site.Title (not (eq $title .Site.Title)) }}
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) .Site.Title }}
{{- end }}
{{- if .Params.menuTitle }}
{{- warnf "%q: DEPRECATED frontmatter 'menutitle' found, use 'linktitle' instead" $page.File.Filename }}
{{- end }}
<title>{{ $title }}</title> <title>{{ $title }}</title>
{{- if .IsTranslated -}} {{- if .IsTranslated -}}

View file

@ -1 +1,2 @@
<h1 id="{{ .Title | plainify | anchorize }}">{{ .Title }}</h1> {{- $title := partial "pageHelper/title.hugo" (dict "page" .) }}
<h1 id="{{ $title | plainify | anchorize }}">{{ $title }}</h1>

View file

@ -1,5 +1,6 @@
{{- if not .Title }} {{- $title := partial "pageHelper/title.hugo" (dict "page" .) }}
{{- $title := .Site.Title }} {{- if not $title }}
{{- $title := site.Title }}
<h1 id="{{ $title | plainify | anchorize }}">{{ $title }}</h1> <h1 id="{{ $title | plainify | anchorize }}">{{ $title }}</h1>
{{- end }} {{- end }}

View file

@ -4,26 +4,13 @@
{{- $basename := "index" }} {{- $basename := "index" }}
{{- if eq $outputFormat "searchpage" }} {{- if eq $outputFormat "searchpage" }}
{{- $basename = partial "BaseName.hugo" $format.RelPermalink }} {{- $basename = partial "BaseName.hugo" $format.RelPermalink }}
{{- end }}
{{- $title := .Title }}
{{- if eq $outputFormat "searchpage" }}
{{- $title = T "Search" }}
{{- else if eq .Kind "taxonomy" }}
{{- $title = default (default .Data.Plural (i18n .Data.Plural)) .Params.Title }}
{{- else if eq .Kind "term" }}
{{- $taxonomy_page := .Site.GetPage .Data.Plural }}
{{- $title = default (default .Data.Singular (i18n .Data.Singular)) $taxonomy_page.Params.SingularTitle }}
{{- $title = printf "%s %s %s" (default (humanize .Data.Term | strings.Title) .Title) (default "::" .Site.Params.titleSeparator) $title }}
{{- end }}
{{- if and $title .Site.Title (not (eq $title .Site.Title)) }}
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) .Site.Title }}
{{- 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) }}">
{{- with or site.Title site.Params.title | plainify }} {{- with or site.Title site.Params.title | plainify }}
<meta property="og:site_name" content="{{ . }}"> <meta property="og:site_name" content="{{ . }}">
{{- end }} {{- end }}
<meta property="og:title" content="{{ $title | plainify }}"> <meta property="og:title" content="{{ partial "pageHelper/fullTitle.hugo" (dict "page" . "invert" true "format" $format "outputFormat" $outputFormat) | plainify }}">
{{- with or .Description .Summary site.Params.description | plainify }} {{- with or .Description .Summary site.Params.description | plainify }}
<meta property="og:description" content="{{ . }}"> <meta property="og:description" content="{{ . }}">
@ -36,20 +23,7 @@
{{- if .IsPage }} {{- if .IsPage }}
<meta property="og:type" content="article"> <meta property="og:type" content="article">
{{- with .FirstSection }} {{- with .FirstSection }}
{{- $title := .Title }} <meta property="article:section" content="{{ partial "pageHelper/fullTitle.hugo" (dict "page" . "invert" true "format" $format "outputFormat" $outputFormat) | plainify }}">
{{- if eq $outputFormat "searchpage" }}
{{- $title = T "Search" }}
{{- else if eq .Kind "taxonomy" }}
{{- $title = default (default .Data.Plural (i18n .Data.Plural)) .Params.Title }}
{{- else if eq .Kind "term" }}
{{- $taxonomy_page := .Site.GetPage .Data.Plural }}
{{- $title = default (default .Data.Singular (i18n .Data.Singular)) $taxonomy_page.Params.SingularTitle }}
{{- $title = printf "%s %s %s" (default (humanize .Data.Term | strings.Title) .Title) (default "::" .Site.Params.titleSeparator) $title }}
{{- end }}
{{- if and $title .Site.Title (not (eq $title .Site.Title)) }}
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) .Site.Title }}
{{- end }}
<meta property="article:section" content="{{ $title | plainify }}">
{{- end }} {{- end }}
{{- $iso8601 := "2006-01-02T15:04:05-07:00" }} {{- $iso8601 := "2006-01-02T15:04:05-07:00" }}
{{- with .PublishDate }} {{- with .PublishDate }}

View file

@ -14,6 +14,7 @@
{{- $currentNode.Store.Set $has true }} {{- $currentNode.Store.Set $has true }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- template "relearn-structure" dict "node" .Site.Home "currentnode" $currentNode "hiddenstem" false "hiddencurrent" false }} {{- template "relearn-structure" dict "node" .Site.Home "currentnode" $currentNode "hiddenstem" false "hiddencurrent" false }}
{{- define "relearn-structure" }} {{- define "relearn-structure" }}
{{- $currentNode := .currentnode }} {{- $currentNode := .currentnode }}
@ -24,7 +25,7 @@
{{- $isChildren := eq $currentNode .node.Parent }} {{- $isChildren := eq $currentNode .node.Parent }}
{{- if $isSelf }} {{- if $isSelf }}
{{- $currentNode.Scratch.Set "relearnIsSelfFound" true }} {{- $currentNode.Scratch.Set "relearnIsSelfFound" true }}
{{- end}} {{- end }}
{{- $isSelfFound := eq ($currentNode.Scratch.Get "relearnIsSelfFound") true }} {{- $isSelfFound := eq ($currentNode.Scratch.Get "relearnIsSelfFound") true }}
{{- $isPreSelf := and (not $isSelfFound) (not $isSelf) }} {{- $isPreSelf := and (not $isSelfFound) (not $isSelf) }}
{{- $isPostSelf := and ($isSelfFound) (not $isSelf) }} {{- $isPostSelf := and ($isSelfFound) (not $isSelf) }}
@ -36,19 +37,21 @@
{{- if $isSelf }} {{- if $isSelf }}
{{- $currentNode.Scratch.Set "relearnIsHiddenNode" $hidden_node }} {{- $currentNode.Scratch.Set "relearnIsHiddenNode" $hidden_node }}
{{- $currentNode.Scratch.Set "relearnIsHiddenStem" $hidden_stem }} {{- $currentNode.Scratch.Set "relearnIsHiddenStem" $hidden_stem }}
{{- end}} {{- end }}
{{- $currentNode.Scratch.SetInMap "relearnIsHiddenFrom" .node.RelPermalink $hidden_current_stem }} {{- $currentNode.Scratch.SetInMap "relearnIsHiddenFrom" .node.RelPermalink $hidden_current_stem }}
{{- if not $hidden_from_current }} {{- if or (eq $currentNode.Kind "home") (eq $currentNode.Kind "section") (eq $currentNode.Kind "page") }}
{{- if and $isPreSelf .node.RelPermalink }} {{- if not $hidden_from_current }}
{{- $currentNode.Scratch.Set "relearnPrevPage" .node }} {{- if and $isPreSelf .node.RelPermalink }}
{{- else if and $isPostSelf .node.RelPermalink (eq ($currentNode.Scratch.Get "relearnNextPage") nil) }} {{- $currentNode.Scratch.Set "relearnPrevPage" .node }}
{{- $currentNode.Scratch.Set "relearnNextPage" .node }} {{- else if and $isPostSelf .node.RelPermalink (eq ($currentNode.Scratch.Get "relearnNextPage") nil) }}
{{- end}} {{- $currentNode.Scratch.Set "relearnNextPage" .node }}
{{- end }}
{{- end }}
{{- end }} {{- end }}
{{- $pages := partial "pageHelper/pagesBy.html" (dict "page" .node "hidden" true) }} {{- $pages := partial "pageHelper/pagesBy.html" (dict "page" .node "hidden" true) }}
{{- range $pages }} {{- range $pages }}
{{- template "relearn-structure" dict "node" . "currentnode" $currentNode "hiddenstem" $hidden_stem "hiddencurrent" $hidden_from_current }} {{- template "relearn-structure" dict "node" . "currentnode" $currentNode "hiddenstem" $hidden_stem "hiddencurrent" $hidden_from_current }}
{{- end}} {{- end }}
{{- end }} {{- end }}

View file

@ -0,0 +1,11 @@
{{- $title := partial "pageHelper/title.hugo" . }}
{{- with .page }}
{{- if and $title site.Title (not (eq $title site.Title)) }}
{{- if $.invert }}
{{- $title = printf "%s %s %s" $title (default "::" site.Params.titleSeparator) site.Title }}
{{- else }}
{{- $title = printf "%s %s %s" site.Title (default "::" site.Params.titleSeparator) $title }}
{{- end }}
{{- end }}
{{- end }}
{{- return $title }}

View file

@ -0,0 +1,32 @@
{{- $title := "" }}
{{- with .page }}
{{- if .Params.menuTitle }}
{{- warnf "%q: DEPRECATED frontmatter 'menutitle' found, use 'linktitle' instead" $.File.Filename }}
{{- end }}
{{- $format := $.format | default (partial "get-format.hugo" .) }}
{{- $outputFormat := $.outputFormat | default (partial "output-format.hugo" (dict "page" . "format" $format)) }}
{{- $title = .Title }}
{{- if $.useLinkTitle }}
{{- $title = or $.page.Params.menuTitle $.page.LinkTitle $title }}
{{- end }}
{{- if eq $outputFormat "searchpage" }}
{{- $title = T "Search" }}
{{- else if eq .Kind "home" }}
{{- $title = or $title site.Title }}
{{- else if eq .Kind "taxonomy" }}
{{- $title = default (default .Data.Plural (i18n .Data.Plural)) .Params.Title }}
{{- else if eq .Kind "term" }}
{{- $taxonomy_page := .Site.GetPage .Data.Plural }}
{{- $taxonomy_title := default (default $taxonomy_page.Data.Singular (i18n $taxonomy_page.Data.Singular)) $taxonomy_page.Params.SingularTitle }}
{{- $term_title := default (humanize .Data.Term | strings.Title) .Title }}
{{- if $.useLinkTitle }}
{{- $title = printf "%s" $term_title }}
{{- else if $.invert }}
{{- $title = printf "%s %s %s" $term_title (default "::" .Site.Params.titleSeparator) $taxonomy_title }}
{{- else }}
{{- $title = printf "%s %s %s" $taxonomy_title (default "::" .Site.Params.titleSeparator) $term_title }}
{{- end }}
{{- end }}
{{- end }}
{{- return $title }}

View file

@ -5,36 +5,25 @@
{{- $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) }}
{{- $showPrevNext := (and (not .Params.disableNextPrev) (not .Site.Params.disableNextPrev)) }} {{- $showPrevNext := (and (not .Params.disableNextPrev) (not .Site.Params.disableNextPrev)) }}
{{- if and (or (eq $outputFormat "html") (eq $outputFormat "searchpage")) $showPrevNext }} {{- if $showPrevNext }}
{{- $endarrow := "🡒" }} {{- $endarrow := "🡒" }}
{{- if eq (.Language.LanguageDirection | default (T "Reading-direction") | default "ltr") "rtl" }} {{- if eq (.Language.LanguageDirection | default (T "Reading-direction") | default "ltr") "rtl" }}
{{- $endarrow = "🡐" }} {{- $endarrow = "🡐" }}
{{- end }} {{- end }}
{{- $next := "" }} {{- $next := .Scratch.Get "relearnNextPage" }}
{{- $nextTitle := .Title }} {{- if eq $outputFormat "searchpage" }}
{{- if eq .Page.Kind "taxonomy" }} {{- $next = "" }}
{{- /* go to first term page */}}
{{- $pages := partialCached "partials/pageHelper/taxonomyPages.html" . . }}
{{- $next = (index $pages 0).Page }}
{{- if $next }}
{{- $taxonomy_page := .Page }}
{{- $nextTitle = default (default $next.Data.Singular (i18n $next.Data.Singular)) $taxonomy_page.Params.SingularTitle }}
{{- $nextTitle = printf "%s %s %s" $nextTitle (default "::" $next.Site.Params.titleSeparator) (default (humanize $next.Data.Term | strings.Title) $next.Title) }}
{{- 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 }}
{{- $pages := partialCached "partials/pageHelper/taxonomyPages.html" $taxonomy_page $taxonomy_page }} {{- $pages := partialCached "partials/pageHelper/taxonomyPages.html" $taxonomy_page $taxonomy_page }}
{{- $next = partial "partials/pageHelper/next.html" (dict "collection" $pages "item" .) }} {{- $next = partial "partials/pageHelper/next.html" (dict "collection" $pages "item" .) }}
{{- if $next }} {{- else if eq .Page.Kind "taxonomy" }}
{{- $nextTitle = default (default $next.Data.Singular (i18n $next.Data.Singular)) $taxonomy_page.Params.SingularTitle }} {{- /* go to first term page */}}
{{- $nextTitle = printf "%s %s %s" $nextTitle (default "::" $next.Site.Params.titleSeparator) (default (humanize $next.Data.Term | strings.Title) $next.Title) }} {{- $pages := partialCached "partials/pageHelper/taxonomyPages.html" . . }}
{{- end }} {{- $next = (index $pages 0).Page }}
{{- else if or (ne $outputFormat "html") (not (.Scratch.Get "relearnNextPage")) }}
{{- else }}
{{- $next = .Scratch.Get "relearnNextPage" }}
{{- $nextTitle = $next.Title }}
{{- end }} {{- end }}
{{- $nextTitle := partial "pageHelper/title.hugo" (dict "page" $next "format" $format "outputFormat" $outputFormat) }}
{{- partial "topbar/func/button.html" (dict {{- partial "topbar/func/button.html" (dict
"page" . "page" .
"class" "topbar-button-next" "class" "topbar-button-next"

View file

@ -5,36 +5,23 @@
{{- $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) }}
{{- $showPrevNext := (and (not .Params.disableNextPrev) (not .Site.Params.disableNextPrev)) }} {{- $showPrevNext := (and (not .Params.disableNextPrev) (not .Site.Params.disableNextPrev)) }}
{{- if and (or (eq $outputFormat "html") (eq $outputFormat "searchpage")) $showPrevNext }} {{- if $showPrevNext }}
{{- $startarrow := "🡐" }} {{- $startarrow := "🡐" }}
{{- if eq (.Language.LanguageDirection | default (T "Reading-direction") | default "ltr") "rtl" }} {{- if eq (.Language.LanguageDirection | default (T "Reading-direction") | default "ltr") "rtl" }}
{{- $startarrow = "🡒" }} {{- $startarrow = "🡒" }}
{{- end }} {{- end }}
{{- $prev := "" }} {{- $prev := .Scratch.Get "relearnPrevPage" | default .Site.Home }}
{{- $prevTitle := .Title }} {{- if eq $outputFormat "searchpage" }}
{{- if and (eq .RelPermalink .Site.Home.RelPermalink) (eq $outputFormat "html") }} {{- $outputFormat = "html" }}
{{- else if eq .Page.Kind "taxonomy" }} {{- else if eq .Page.Kind "home" }}
{{- $prev = .Site.Home }} {{- $prev = "" }}
{{- $prevTitle = $prev.Title }}
{{- 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 }}
{{- $pages := partialCached "partials/pageHelper/taxonomyPages.html" $taxonomy_page $taxonomy_page }} {{- $pages := partialCached "partials/pageHelper/taxonomyPages.html" $taxonomy_page $taxonomy_page }}
{{- $prev = partial "partials/pageHelper/prev.html" (dict "collection" $pages "item" .) }} {{- $prev = partial "partials/pageHelper/prev.html" (dict "collection" $pages "item" .) | default $taxonomy_page }}
{{- if not $prev }} {{- end }}
{{- $prev = $taxonomy_page }} {{- $prevTitle := partial "pageHelper/title.hugo" (dict "page" $prev "format" $format "outputFormat" $outputFormat) }}
{{- $prevTitle = default (default $prev.Data.Plural (i18n $prev.Data.Plural)) $prev.Params.Title }}
{{- else }}
{{- $prevTitle = default (default $prev.Data.Singular (i18n $prev.Data.Singular)) $taxonomy_page.Params.SingularTitle }}
{{- $prevTitle = printf "%s %s %s" $prevTitle (default "::" $prev.Site.Params.titleSeparator) (default (humanize $prev.Data.Term | strings.Title) $prev.Title) }}
{{- end }}
{{- else if or (ne $outputFormat "html") (not (.Scratch.Get "relearnPrevPage")) }}
{{- $prev = .Site.Home }}
{{- $prevTitle = $prev.Title }}
{{- else }}
{{- $prev = .Scratch.Get "relearnPrevPage" }}
{{- $prevTitle = $prev.Title }}
{{- end}}
{{- partial "topbar/func/button.html" (dict {{- partial "topbar/func/button.html" (dict
"page" . "page" .
"class" "topbar-button-prev" "class" "topbar-button-prev"

View file

@ -1,20 +1,4 @@
{{- /* based on Hugo 0.125.0 _internal/twitter_cardss.html but with modified title */}} {{- /* based on Hugo 0.125.0 _internal/twitter_cardss.html but with modified title */}}
{{- $format := partial "get-format.hugo" . }}
{{- $outputFormat := partial "output-format.hugo" (dict "page" . "format" $format) }}
{{- $title := .Title }}
{{- if eq $outputFormat "searchpage" }}
{{- $title = T "Search" }}
{{- else if eq .Kind "taxonomy" }}
{{- $title = default (default .Data.Plural (i18n .Data.Plural)) .Params.Title }}
{{- else if eq .Kind "term" }}
{{- $taxonomy_page := .Site.GetPage .Data.Plural }}
{{- $title = default (default .Data.Singular (i18n .Data.Singular)) $taxonomy_page.Params.SingularTitle }}
{{- $title = printf "%s %s %s" (default (humanize .Data.Term | strings.Title) .Title) (default "::" .Site.Params.titleSeparator) $title }}
{{- end }}
{{- if and $title .Site.Title (not (eq $title .Site.Title)) }}
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) .Site.Title }}
{{- end }}
{{- $images := partial "_funcs/get-page-images" . }} {{- $images := partial "_funcs/get-page-images" . }}
{{- with index $images 0 }} {{- with index $images 0 }}
<meta name="twitter:card" content="summary_large_image"> <meta name="twitter:card" content="summary_large_image">
@ -22,7 +6,7 @@
{{- else }} {{- else }}
<meta name="twitter:card" content="summary"> <meta name="twitter:card" content="summary">
{{- end }} {{- end }}
<meta name="twitter:title" content="{{ $title }}"> <meta name="twitter:title" content="{{ partial "pageHelper/fullTitle.hugo" (dict "page" . "invert" true) }}">
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}"> <meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}">
{{- $twitterSite := "" }} {{- $twitterSite := "" }}