mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 17:53:07 +00:00
29 lines
No EOL
968 B
Go Template
29 lines
No EOL
968 B
Go Template
{{- $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 }}
|
|
{{- $prev = .Scratch.Get "relearnPrevPage" }}
|
|
{{- end }}
|
|
{{- 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 }}
|
|
{{- end }} |