{{- $page := .page }} {{- $menuID := cast.ToString .menuID }} {{- if $menuID }} {{- with index site.Menus $menuID }} {{- partial "inline/single/walk.html" (dict "page" $page "menuEntries" . ) }} {{- end }} {{- end }} {{- partial "inline/single/up.html" (dict "page" $page ) }} {{- define "partials/inline/single/walk.html" }} {{- $page := .page }} {{- $found := false }} {{- range .menuEntries }} {{- if $page.IsMenuCurrent .Menu . }} {{- $found = . }} {{- end }} {{- end }} {{ if eq $found false}} {{- range .menuEntries }} {{- with .Children }} {{- partial "inline/single/walk.html" (dict "page" $page "menuEntries" . ) }} {{- end }} {{- end }} {{- else }} {{ $found_weight := $found.Weight }} {{ $found_url := $found.URL }} {{- range (where (where (where (where .menuEntries "Params.placeholder" "ne" true) "Params.nonpage" "ne" true) "URL" "ne" $found_url) "Weight" "le" $found_weight) | last 1 }} Previous: {{ .Name }}, {{- end }} {{- range (where (where (where (where .menuEntries "Params.placeholder" "ne" true) "Params.nonpage" "ne" true) "URL" "ne" $found_url) "Weight" "gt" $found_weight) | first 1 }} Next: {{ .Name }}, {{- end }} {{- end }} {{- end }} {{- define "partials/inline/single/up.html" }} {{- $page := .page }} {{- $nearest := true }} Up: {{- range $page.Ancestors }} {{- if .LinkTitle}} {{- if $nearest}} {{ .LinkTitle }} {{- $nearest = false }} {{- else}} [{{ .LinkTitle }}] {{- end }} {{- end }} {{- end }} {{- end }}