diff --git a/layouts/partials/helpers/get-pages.html b/layouts/partials/helpers/get-pages.html new file mode 100644 index 0000000..8e06483 --- /dev/null +++ b/layouts/partials/helpers/get-pages.html @@ -0,0 +1,10 @@ +{{ $pages:= slice}} +{{ range . }} + {{ if .HasChildren }} + {{ $nestedPages:=partial "helpers/get-pages.html" .Children }} + {{ $pages = $pages | append $nestedPages }} + {{ else }} + {{ $pages = $pages | append .Page }} + {{ end }} +{{ end }} +{{ return $pages}} diff --git a/layouts/partials/navigators/next-prev-navigator.html b/layouts/partials/navigators/next-prev-navigator.html index f87c369..3738c67 100644 --- a/layouts/partials/navigators/next-prev-navigator.html +++ b/layouts/partials/navigators/next-prev-navigator.html @@ -1,33 +1,39 @@ +{{ $curPage := . }} +{{ $prevPage := "" }} +{{ $nextPage := "" }} + + +{{ $pages := partial "helpers/get-pages.html" site.Menus.sidebar }} + + +{{ $idx := 0 }} +{{ range $pages }} + {{ if eq .RelPermalink $curPage.RelPermalink }} + {{ $prevPage = index $pages (sub $idx 1) }} + {{ $nextPage = index $pages (add $idx 1) }} + {{ end }} + {{ $idx = add $idx 1 }} +{{ end }} +