nav: display translated taxonomy and terms title #772

This commit is contained in:
Sören Weber 2024-02-14 23:16:08 +01:00
parent af209c3f49
commit 288c6609d0
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
2 changed files with 21 additions and 2 deletions

View file

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

View file

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