From d30367173e81268b3d6b3740dca78194204dea56 Mon Sep 17 00:00:00 2001 From: John Haugabook Date: Wed, 24 Jan 2024 21:04:42 -0500 Subject: [PATCH] layout partial - list - sequential links Added a partial that creates sequential page navigation. At bottom of each page. Thought it would make the site a bit better as when reading sequentially you can click to the next page in the current section. Some of the links had to be modified with JavaScript as was not able to achieve sequential weight navigation with Hugo. --- layouts/_default/single.html | 55 +++++++------ layouts/partials/list.html | 150 +++++++++++++++++++++++++++++++++++ 2 files changed, 177 insertions(+), 28 deletions(-) create mode 100644 layouts/partials/list.html diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 13a6ff67..3395a1a6 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,28 +1,27 @@ -{{ define "main" }} -

{{ .Title }}

- - {{ with .Description }} -

{{.}}

- {{ end }} - -
- {{ .Content }} - -

- {{ i18n "lastUpdated" }} {{ .Lastmod.Format "January 2, 2006" }}{{ with .File }} · {{ i18n "improvePage" }}{{ end }} - - {{ if .IsTranslated }} -
- - {{ i18n "otherTranslations" }} - - {{ range .Translations }} - {{ .Language.LanguageName }} - {{ end }} - {{ end }} -

- -
-{{ end }} +{{ define "main" }} +

{{ .Title }}

+ {{ with .Description }} +

{{.}}

+ {{ end }} + +
+ {{ .Content }} + {{ partial "list.html" . }} +

+ {{ i18n "lastUpdated" }} {{ .Lastmod.Format "January 2, 2006" }}{{ with .File }} · {{ i18n "improvePage" }}{{ end }} + + {{ if .IsTranslated }} +
+ + {{ i18n "otherTranslations" }} + + {{ range .Translations }} + {{ .Language.LanguageName }} + {{ end }} + {{ end }} +

+ +
+{{ end }} diff --git a/layouts/partials/list.html b/layouts/partials/list.html new file mode 100644 index 00000000..926aa6af --- /dev/null +++ b/layouts/partials/list.html @@ -0,0 +1,150 @@ +{{ $sideMargin := "50px" }} +{{ $verticalMargin := "30px" }} +{{ $fontSize:= "12pt" }} + +{{ $currentPage := . }} +{{ $curWeight := -1 }} + +{{ range .Site.Menus.docs }} + {{ if .HasChildren }} + {{ $extractParent := $currentPage.Parent.Page }} + {{ $currentParent := (replaceRE "Page\\(\\/(.*)\\)" "$1" $extractParent) }} + {{ range .Children }} + {{ if eq $currentParent (.Parent) }} + {{ if .Weight }} + + {{ if $currentPage.IsMenuCurrent "docs" . }} + +
+ Previous - +
+ Next - +
+ + + {{ end }} + {{ else }} + + {{ if $currentPage.IsMenuCurrent "docs" . }} +
+ {{ with $currentPage.NextInSection }} + Previous - {{ .Name }} + {{ end }} +
+ {{ with $currentPage.PrevInSection }} + Next - {{ .Name }} + {{ end }} +
+ + + {{ end }} + {{ end }} + {{ end }} + {{ end }} + {{ else }} + {{ $extractParent := $currentPage.Parent.Page }} + {{ $currentParent := (replaceRE "Page\\(\\/(.*)\\)" "$1" $extractParent) }} + {{ if eq $currentParent (.Parent) }} + {{ if .Weight }} + + {{ if $currentPage.IsMenuCurrent "docs" . }} + +
+ Previous - +
+ Next - +
+ + + {{ end }} + {{ else }} + {{ if $currentPage.IsMenuCurrent "docs" . }} + +
+ {{ with $currentPage.NextInSection }} + Previous - {{ .Name }} + {{ end }} +
+ {{ with $currentPage.PrevInSection }} + Next - {{ .Name }} + {{ end }} +
+ + + {{ end }} + {{ end }} + {{ end }} + {{ end }} +{{ end }} + +