github.com/square/finch@v0.0.0-20240412205204-6530c03e2b96/docs/themes/hugo-geekdoc/layouts/partials/menu-nextprev.html (about) 1 {{ $current := . }} 2 {{ $site := .Site }} 3 {{ $current.Scratch.Set "prev" false }} 4 {{ $current.Scratch.Set "getNext" false }} 5 6 {{ $current.Scratch.Set "nextPage" false }} 7 {{ $current.Scratch.Set "prevPage" false }} 8 9 {{ template "menu_nextprev" dict "sect" $.Site.Data.menu.main.main "current" $current "site" $site }} 10 11 {{ define "menu_nextprev" }} 12 {{ $current := .current }} 13 {{ $site := .site }} 14 15 {{ range sort (default (seq 0) .sect) "weight" }} 16 {{ $current.Scratch.Set "current" $current }} 17 {{ $current.Scratch.Set "site" $site }} 18 19 {{ $ref := default false .ref }} 20 {{ if $ref }} 21 {{ $site := $current.Scratch.Get "site" }} 22 {{ $this := $site.GetPage .ref }} 23 {{ $current := $current.Scratch.Get "current" }} 24 25 {{ if reflect.IsMap .name }} 26 {{ $current.Scratch.Set "refName" (index .name $site.Language.Lang) }} 27 {{ else }} 28 {{ $current.Scratch.Set "refName" .name }} 29 {{ end }} 30 {{ $name := $current.Scratch.Get "refName" }} 31 32 {{ if $current.Scratch.Get "getNext" }} 33 {{ $current.Scratch.Set "nextPage" (dict "name" $name "this" $this) }} 34 {{ $current.Scratch.Set "getNext" false }} 35 {{ end }} 36 37 {{ if eq $current $this }} 38 {{ $current.Scratch.Set "prevPage" ($current.Scratch.Get "prev") }} 39 {{ $current.Scratch.Set "getNext" true }} 40 {{ end }} 41 42 {{ $current.Scratch.Set "prev" (dict "name" $name "this" $this) }} 43 {{ end }} 44 45 {{ $sub := default false .sub }} 46 {{ if $sub }} 47 {{ template "menu_nextprev" dict "sect" $sub "current" ($current.Scratch.Get "current") "site" ($current.Scratch.Get "site") }} 48 {{ end }} 49 {{ end }} 50 {{ end }} 51 52 {{ $showPrevNext := (and (default true .Site.Params.GeekdocNextPrev) .Site.Params.GeekdocMenuBundle) }} 53 {{ if $showPrevNext }} 54 <span class="gdoc-page__nav"> 55 {{ with ($current.Scratch.Get "prevPage") }} 56 <a 57 class="gdoc-page__nav--prev flex align-center" 58 href="{{ .this.RelPermalink }}" 59 title="{{ .name }}" 60 > 61 <i class="gdoc-icon">gdoc_arrow_left_alt</i> 62 {{ .name }} 63 </a> 64 {{ end }} 65 </span> 66 <span class="gdoc-page__nav"> 67 {{ with ($current.Scratch.Get "nextPage") }} 68 <a 69 class="gdoc-page__nav--next flex align-center" 70 href="{{ .this.RelPermalink }}" 71 title="{{ .name }}" 72 > 73 {{ .name }} 74 <i class="gdoc-icon">gdoc_arrow_right_alt</i> 75 </a> 76 {{ end }} 77 </span> 78 {{ end }}