hugo-theme-relearn/layouts/partials/topbar/button/prev.html

38 lines
1.7 KiB
HTML
Raw Normal View History

2023-09-18 18:24:49 +00:00
{{- $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)) }}
2024-04-07 19:41:06 +00:00
{{- if $showPrevNext }}
2023-09-18 18:24:49 +00:00
{{- $startarrow := "🡐" }}
{{- if eq (.Language.LanguageDirection | default (T "Reading-direction") | default "ltr") "rtl" }}
2023-09-18 18:24:49 +00:00
{{- $startarrow = "🡒" }}
{{- end }}
{{- $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" }}
{{- $prev = .Site.Home }}
{{- end }}
{{- 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 }}
{{- $pages := partialCached "partials/pageHelper/taxonomyPages.html" $taxonomy_page $taxonomy_page }}
2024-04-07 19:41:06 +00:00
{{- $prev = partial "partials/pageHelper/prev.html" (dict "collection" $pages "item" .) | default $taxonomy_page }}
{{- else if eq .Page.Kind "taxonomy" }}
{{- $prev = .Site.Home }}
2024-04-07 19:41:06 +00:00
{{- end }}
{{- $prevTitle := partial "pageHelper/title.hugo" (dict "page" $prev "outputFormat" "html") }}
2023-09-18 18:24:49 +00:00
{{- partial "topbar/func/button.html" (dict
"page" .
"class" "topbar-button-prev"
"href" (partial "relLangPrettyUglyURL.hugo" (dict "to" $prev))
"icon" "chevron-left"
"onwidths" $onwidths
"onwidthm" $onwidthm
"onwidthl" $onwidthl
"hint" (printf "%s (%s)" $prevTitle ($startarrow | safeHTML))
2023-09-18 18:24:49 +00:00
)}}
{{- end }}
{{- end }}