diff options
Diffstat (limited to 'layouts/partials/single/bottom_nav.html')
-rw-r--r-- | layouts/partials/single/bottom_nav.html | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/layouts/partials/single/bottom_nav.html b/layouts/partials/single/bottom_nav.html new file mode 100644 index 0000000..88dbf9c --- /dev/null +++ b/layouts/partials/single/bottom_nav.html @@ -0,0 +1,82 @@ +<hr> +{{- $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 }} + +<!-- Check if current entries contain current page --> + {{- range .menuEntries }} + {{- if $page.IsMenuCurrent .Menu . }} + {{- $found = . }} + {{- end }} + {{- end }} + +{{ if eq $found false}} +<!-- current page not found, go to next levels --> + {{- range .menuEntries }} + {{- with .Children }} + {{- partial "inline/single/walk.html" (dict "page" $page "menuEntries" . ) }} + {{- end }} + {{- end }} +{{- else }} +<!-- current page found --> + +{{ $found_weight := $found.Weight }} +{{ $found_url := $found.URL }} + +<!-- search for prev page --> +{{- range (where + (where + (where + (where + .menuEntries + "Params.placeholder" "ne" true) + "Params.nonpage" "ne" true) + "URL" "ne" $found_url) +"Weight" "le" $found_weight) | last 1 }} + + Prev: <a href="{{.URL}}">{{ .Name }}</a>, +{{- end }} + +<!-- search for next page --> +{{- 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: <a href="{{.URL}}">{{ .Name }}</a>, +{{- end }} + +{{- end }} + +{{- end }} + +{{- define "partials/inline/single/up.html" }} + {{- $page := .page }} + {{- $nearest := true }} + Up: + {{- range $page.Ancestors }} + {{- if .LinkTitle}} + {{- if $nearest}} + <a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a> + {{- $nearest = false }} + {{- else}} + [<a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>] + {{- end }} + {{- end }} + {{- end }} +{{- end }} |