2024-09-07 22:12:10 +00:00
|
|
|
{{- $prev := "" }}
|
|
|
|
{{- 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.Path }}
|
|
|
|
{{- $prev = partial "inline/prev-term" (dict "collection" $pages "item" .) | default $taxonomy_page }}
|
|
|
|
{{- else if eq .Page.Kind "taxonomy" }}
|
|
|
|
{{- $prev = .Site.Home }}
|
|
|
|
{{- else if eq .Page.Kind "home" }}
|
|
|
|
{{- /* no prev here */}}
|
|
|
|
{{- else }}
|
2024-09-11 08:12:14 +00:00
|
|
|
{{- $prev = or (partial "inline/prev_page" .) .Site.Home }}
|
2023-12-01 00:03:51 +00:00
|
|
|
{{- end }}
|
2024-09-07 22:12:10 +00:00
|
|
|
{{- return $prev }}
|
|
|
|
|
|
|
|
{{- define "partials/inline/prev-term" }}
|
|
|
|
{{- $collection := .collection }}
|
|
|
|
{{- $item := .item }}
|
|
|
|
{{- $last := "" }}
|
|
|
|
{{- $result := "" }}
|
|
|
|
{{- range $collection }}
|
|
|
|
{{- if eq $item .Page.Page }}
|
|
|
|
{{- $result = $last }}
|
|
|
|
{{- break }}
|
|
|
|
{{- end }}
|
|
|
|
{{- $last = .Page.Page }}
|
|
|
|
{{- end }}
|
|
|
|
{{- return $result }}
|
2024-09-11 08:12:14 +00:00
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{- define "partials/inline/prev_page" }}
|
|
|
|
{{- $previousVisible := "" }}
|
|
|
|
{{- $currentNode := . }}
|
|
|
|
{{- with partial "inline/parent" $currentNode }}
|
|
|
|
{{- $parent := . }}
|
|
|
|
{{- $pages := partialCached "_relearn/pages.gotmpl" (dict "page" $parent) $parent.Path }}
|
|
|
|
{{- $previousSibling := partial "inline/prev_sibling" (dict "siblings" $pages "currentNode" $currentNode) }}
|
|
|
|
{{- if $previousSibling }}
|
|
|
|
{{- $previousVisible = partial "inline/rightmost_descendant" $previousSibling }}
|
|
|
|
{{- if not $previousVisible }}
|
|
|
|
{{- if $previousSibling.RelPermalink }}
|
|
|
|
{{- $previousVisible = $previousSibling }}
|
|
|
|
{{- else }}
|
|
|
|
{{- $previousVisible = partial "inline/prev_page" $previousSibling }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
{{- else }}
|
|
|
|
{{- if $parent.RelPermalink }}
|
|
|
|
{{- $previousVisible = $parent }}
|
|
|
|
{{- else }}
|
|
|
|
{{- $previousVisible = partial "inline/prev_page" $parent }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
{{- return $previousVisible }}
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{- define "partials/inline/prev_sibling" }}
|
|
|
|
{{- $previousSibling := "" }}
|
|
|
|
{{- $siblings := .siblings }}
|
|
|
|
{{- $currentNode := .currentNode }}
|
|
|
|
{{- range $siblings }}
|
|
|
|
{{- if eq . $currentNode }}
|
|
|
|
{{- break }}
|
|
|
|
{{- else if not (or (.Params.hidden) (eq .Title "")) }}
|
|
|
|
{{- $previousSibling = . }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
{{- return $previousSibling }}
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{- define "partials/inline/rightmost_descendant" }}
|
|
|
|
{{- $rightmostVisible := . }}
|
|
|
|
{{- $pages := (partialCached "_relearn/pages.gotmpl" (dict "page" $rightmostVisible) $rightmostVisible.Path) | collections.Reverse }}
|
|
|
|
{{- range $pages }}
|
|
|
|
{{- if not (or (.Params.hidden) (eq .Title "")) }}
|
|
|
|
{{- with partial "inline/rightmost_descendant" . }}
|
|
|
|
{{- if .RelPermalink }}
|
|
|
|
{{- $rightmostVisible = . }}
|
|
|
|
{{- break }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
{{- return $rightmostVisible }}
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{- define "partials/inline/parent" }}
|
|
|
|
{{- $nonheadless := "" }}
|
|
|
|
{{- $page := . }}
|
|
|
|
{{- $parent := .Parent }}
|
|
|
|
{{- if not (partial "_relearn/pageIsSpecial.gotmpl" $page) }}
|
|
|
|
{{- with $parent }}
|
|
|
|
{{- $pages := partialCached "_relearn/pages.gotmpl" (dict "page" .) .Path }}
|
|
|
|
{{- range $pages }}
|
|
|
|
{{- if eq . $page }}
|
|
|
|
{{- $nonheadless = $parent }}
|
|
|
|
{{- break }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
{{- else }}
|
|
|
|
{{- $nonheadless = $parent }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
{{- return $nonheadless }}
|
2024-09-07 22:12:10 +00:00
|
|
|
{{- end }}
|