From 288c6609d04232b5216753e9e791fb6e7a589488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Wed, 14 Feb 2024 23:16:08 +0100 Subject: [PATCH] nav: display translated taxonomy and terms title #772 --- layouts/partials/topbar/button/next.html | 13 ++++++++++++- layouts/partials/topbar/button/prev.html | 10 +++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/layouts/partials/topbar/button/next.html b/layouts/partials/topbar/button/next.html index 1bf09e9325..276290588e 100644 --- a/layouts/partials/topbar/button/next.html +++ b/layouts/partials/topbar/button/next.html @@ -11,18 +11,29 @@ {{- $endarrow = "🡐" }} {{- end }} {{- $next := "" }} + {{- $nextTitle := .Title }} {{- if eq .Page.Kind "taxonomy" }} {{- /* 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" }} {{- /* go to next term page */}} {{- $taxonomy_page := .Site.GetPage .Data.Plural }} {{- $pages := partialCached "partials/pageHelper/taxonomyPages.html" $taxonomy_page $taxonomy_page }} {{- $next = partial "partials/pageHelper/next.html" (dict "collection" $pages "item" .) }} + {{- if $next }} + {{- $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 or (ne $outputFormat "html") (not (.Scratch.Get "relearnNextPage")) }} {{- else }} {{- $next = .Scratch.Get "relearnNextPage" }} + {{- $nextTitle = $next.Title }} {{- end }} {{- partial "topbar/func/button.html" (dict "page" . @@ -32,7 +43,7 @@ "onwidths" $onwidths "onwidthm" $onwidthm "onwidthl" $onwidthl - "hint" (printf "%s (%s)" ($next | default .).Title ($endarrow | safeHTML)) + "hint" (printf "%s (%s)" $nextTitle ($endarrow | safeHTML)) )}} {{- end }} {{- end }} \ No newline at end of file diff --git a/layouts/partials/topbar/button/prev.html b/layouts/partials/topbar/button/prev.html index 12a4e55729..3e33f6d269 100644 --- a/layouts/partials/topbar/button/prev.html +++ b/layouts/partials/topbar/button/prev.html @@ -11,9 +11,11 @@ {{- $startarrow = "🡒" }} {{- end }} {{- $prev := "" }} + {{- $prevTitle := .Title }} {{- if and (eq .RelPermalink .Site.Home.RelPermalink) (eq $outputFormat "html") }} {{- else if eq .Page.Kind "taxonomy" }} {{- $prev = .Site.Home }} + {{- $prevTitle = $prev.Title }} {{- else if eq .Page.Kind "term" }} {{- /* go to previous term page or taxonomy page if it is the first term */}} {{- $taxonomy_page := .Site.GetPage .Data.Plural }} @@ -21,11 +23,17 @@ {{- $prev = partial "partials/pageHelper/prev.html" (dict "collection" $pages "item" .) }} {{- if not $prev }} {{- $prev = $taxonomy_page }} + {{- $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 "page" . @@ -35,7 +43,7 @@ "onwidths" $onwidths "onwidthm" $onwidthm "onwidthl" $onwidthl - "hint" (printf "%s (%s)" ($prev | default .).Title ($startarrow | safeHTML)) + "hint" (printf "%s (%s)" $prevTitle ($startarrow | safeHTML)) )}} {{- end }} {{- end }} \ No newline at end of file