mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2025-02-18 17:50:06 +00:00
arrownav: optimize #891
This commit is contained in:
parent
825f547781
commit
07cd94cc09
4 changed files with 59 additions and 43 deletions
|
@ -1,13 +1,30 @@
|
|||
{{- $collection := .collection }}
|
||||
{{- $item := .item }}
|
||||
{{- $found := false }}
|
||||
{{- $result := "" }}
|
||||
{{- range $collection }}
|
||||
{{- if $found }}
|
||||
{{- $result = .Page.Page }}
|
||||
{{- break }}
|
||||
{{- else if eq $item .Page.Page }}
|
||||
{{- $found = true }}
|
||||
{{- end }}
|
||||
{{- $next := "" }}
|
||||
{{- if eq .Page.Kind "term" }}
|
||||
{{- /* go to next term page */}}
|
||||
{{- $taxonomy_page := .Site.GetPage .Data.Plural }}
|
||||
{{- $pages := partialCached "partials/_relearn/pagesTaxonomy.gotmpl" $taxonomy_page $taxonomy_page.Path }}
|
||||
{{- $next = partial "inline/next-term" (dict "collection" $pages "item" .) }}
|
||||
{{- else if eq .Page.Kind "taxonomy" }}
|
||||
{{- /* go to first term page */}}
|
||||
{{- $pages := partialCached "partials/_relearn/pagesTaxonomy.gotmpl" . .Path }}
|
||||
{{- $next = (index $pages 0).Page }}
|
||||
{{- else }}
|
||||
{{- $next = .Scratch.Get "relearnNextPage" }}
|
||||
{{- end }}
|
||||
{{- return $result }}
|
||||
{{- return $next }}
|
||||
|
||||
{{- define "partials/inline/next-term" }}
|
||||
{{- $collection := .collection }}
|
||||
{{- $item := .item }}
|
||||
{{- $found := false }}
|
||||
{{- $result := "" }}
|
||||
{{- range $collection }}
|
||||
{{- if $found }}
|
||||
{{- $result = .Page.Page }}
|
||||
{{- break }}
|
||||
{{- else if eq $item .Page.Page }}
|
||||
{{- $found = true }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- return $result }}
|
||||
{{- end }}
|
|
@ -1,12 +1,29 @@
|
|||
{{- $collection := .collection }}
|
||||
{{- $item := .item }}
|
||||
{{- $found := "" }}
|
||||
{{- $result := "" }}
|
||||
{{- range $collection }}
|
||||
{{- if eq $item .Page.Page }}
|
||||
{{- $result = $found }}
|
||||
{{- break }}
|
||||
{{- end }}
|
||||
{{- $found = .Page.Page }}
|
||||
{{- $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 $result }}
|
||||
{{- 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 }}
|
|
@ -8,17 +8,7 @@
|
|||
{{- if eq (.Language.LanguageDirection | default (T "Reading-direction") | default "ltr") "rtl" }}
|
||||
{{- $endarrow = "🡐" }}
|
||||
{{- end }}
|
||||
{{- $next := .Scratch.Get "relearnNextPage" }}
|
||||
{{- if eq .Page.Kind "term" }}
|
||||
{{- /* go to next term page */}}
|
||||
{{- $taxonomy_page := .Site.GetPage .Data.Plural }}
|
||||
{{- $pages := partialCached "partials/_relearn/pagesTaxonomy.gotmpl" $taxonomy_page $taxonomy_page.Path }}
|
||||
{{- $next = partial "partials/_relearn/pageNext.gotmpl" (dict "collection" $pages "item" .) }}
|
||||
{{- else if eq .Page.Kind "taxonomy" }}
|
||||
{{- /* go to first term page */}}
|
||||
{{- $pages := partialCached "partials/_relearn/pagesTaxonomy.gotmpl" . .Path }}
|
||||
{{- $next = (index $pages 0).Page }}
|
||||
{{- end }}
|
||||
{{- $next := partialCached "_relearn/pageNext.gotmpl" . .Path }}
|
||||
{{- $nextTitle := partial "title.gotmpl" (dict "page" $next "outputFormat" "html") }}
|
||||
{{- partial "topbar/func/button.html" (dict
|
||||
"page" .
|
||||
|
|
|
@ -8,15 +8,7 @@
|
|||
{{- 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.Path }}
|
||||
{{- $prev = partial "partials/_relearn/pagePrev.gotmpl" (dict "collection" $pages "item" .) | default $taxonomy_page }}
|
||||
{{- else if eq .Page.Kind "taxonomy" }}
|
||||
{{- $prev = .Site.Home }}
|
||||
{{- end }}
|
||||
{{- $prev := partialCached "_relearn/pagePrev.gotmpl" . .Path }}
|
||||
{{- $prevTitle := partial "title.gotmpl" (dict "page" $prev "outputFormat" "html") }}
|
||||
{{- partial "topbar/func/button.html" (dict
|
||||
"page" .
|
||||
|
|
Loading…
Add table
Reference in a new issue