{{- $currentNode := . -}} {{- define "pagination" -}} {{- $currentNode := .currentnode -}} {{- $menu_exclusion := .menu_exclusion -}} {{- if hasPrefix $currentNode.Permalink .menu.Permalink -}} {{- $currentNode.Scratch.Set "NextPageOK" "OK" -}} {{- if .menu.IsHome -}} {{- $currentNode.Scratch.Set "prevPage" "" -}} {{- else -}} {{- $currentNode.Scratch.Set "prevPage" ($currentNode.Scratch.Get "prevPageTmp") -}} {{- end -}} {{- else -}} {{- if eq ($currentNode.Scratch.Get "NextPageOK") "OK" -}} {{- $currentNode.Scratch.Set "NextPageOK" nil -}} {{ if in $menu_exclusion .menu.Section }} {{- else -}} {{- $currentNode.Scratch.Set "nextPage" .menu -}} {{- end -}} {{- end -}} {{- end -}} {{- $currentNode.Scratch.Set "prevPageTmp" .menu -}} {{- $currentNode.Scratch.Set "pages" .menu.Pages -}} {{- if .menu.IsHome -}} {{- $currentNode.Scratch.Set "pages" .menu.Sections -}} {{- else if .menu.Sections -}} {{- $currentNode.Scratch.Set "pages" (.menu.Pages | union .menu.Sections) -}} {{- end -}} {{- $pages := ($currentNode.Scratch.Get "pages") -}} {{- range $pages.ByWeight -}} {{- template "pagination" dict "menu" . "currentnode" $currentNode "menu_exclusion" $menu_exclusion -}} {{- end -}} {{- end -}}