hugo-theme-relearn/layouts/partials/topbar/button/prev.html
2024-10-11 16:45:40 +02:00

32 lines
No EOL
1.4 KiB
HTML

{{- $onwidths := cond (isset . "onwidths") .onwidths "show" }}
{{- $onwidthm := cond (isset . "onwidthm") .onwidthm "show" }}
{{- $onwidthl := cond (isset . "onwidthl") .onwidthl "show" }}
{{- with .page }}
{{- $showPrevNext := (and (not .Params.disableNextPrev) (not .Site.Params.disableNextPrev)) }}
{{- if $showPrevNext }}
{{- $startarrow := "🡐" }}
{{- if eq (.Language.LanguageDirection | default (T "Reading-direction") | default "ltr") "rtl" }}
{{- $startarrow = "🡒" }}
{{- end }}
{{- $prev := .Scratch.Get "relearnPrevPage" }}
{{- 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 }}
{{- $pages := partialCached "partials/_relearn/pagesTaxonomy.gotmpl" $taxonomy_page $taxonomy_page }}
{{- $prev = partial "partials/_relearn/pagePrev.gotmpl" (dict "collection" $pages "item" .) | default $taxonomy_page }}
{{- else if eq .Page.Kind "taxonomy" }}
{{- $prev = .Site.Home }}
{{- end }}
{{- $prevTitle := partial "title.gotmpl" (dict "page" $prev "outputFormat" "html") }}
{{- partial "topbar/func/button.html" (dict
"page" .
"class" "topbar-button-prev"
"href" (partial "permalink.gotmpl" (dict "to" $prev))
"icon" "chevron-left"
"onwidths" $onwidths
"onwidthm" $onwidthm
"onwidthl" $onwidthl
"hint" (printf "%s (%s)" $prevTitle ($startarrow | safeHTML))
)}}
{{- end }}
{{- end }}