summaryrefslogtreecommitdiff
path: root/layouts/partials/single/bottom_nav.html
diff options
context:
space:
mode:
authormms <michal@sapka.me>2024-04-24 20:00:47 +0200
committermms <michal@sapka.me>2024-04-24 20:00:47 +0200
commit06a78ff287d3fc51cb8f5d04dfdc751379fa10ff (patch)
tree926326f1dd7243405114af72eb65bd72f4446ca2 /layouts/partials/single/bottom_nav.html
parent1c29765a2b4cb5d2702d2476cdc8985a6870d541 (diff)
chore: add bottom nav to BSD
Diffstat (limited to 'layouts/partials/single/bottom_nav.html')
-rw-r--r--layouts/partials/single/bottom_nav.html82
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 }}