From b7dba0713ecee2ec9dc0eadb0f9b3a96b04e61e3 Mon Sep 17 00:00:00 2001 From: Cell <1024@lruihao.cn> Date: Tue, 16 Jan 2024 16:04:57 +0800 Subject: [PATCH] :bug: Fix: fix regular page in post navigation --- layouts/index.archives.html | 2 +- layouts/index.html | 2 +- layouts/index.readme.md | 2 +- layouts/index.rss.xml | 2 +- layouts/partials/init/global.html | 4 ++++ layouts/partials/init/index.html | 2 +- layouts/partials/single/footer.html | 9 +++++++-- layouts/partials/single/related.html | 2 +- 8 files changed, 17 insertions(+), 8 deletions(-) diff --git a/layouts/index.archives.html b/layouts/index.archives.html index ca9097f4..b5fe3e9b 100644 --- a/layouts/index.archives.html +++ b/layouts/index.archives.html @@ -5,7 +5,7 @@ {{- define "content" -}} {{- /* All Posts */ -}} - {{- $pages := where .Site.RegularPages "Type" "posts" -}} + {{- $pages := .Scratch.Get "mainSectionPages" -}}
diff --git a/layouts/index.html b/layouts/index.html index 62290ced..8e563b83 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -28,7 +28,7 @@ {{- /* Posts */ -}} {{- if ne $posts.enable false | and .Site.RegularPages -}} {{- /* Paginate */ -}} - {{- $pages := where .Site.RegularPages "Type" "posts" -}} + {{- $pages := .Scratch.Get "mainSectionPages" -}} {{- if .Site.Params.page.hiddenFromHomePage -}} {{- $pages = where $pages "Params.hiddenfromhomepage" false -}} {{- else -}} diff --git a/layouts/index.readme.md b/layouts/index.readme.md index bb7ff580..d6b93294 100644 --- a/layouts/index.readme.md +++ b/layouts/index.readme.md @@ -1,6 +1,6 @@ # {{ .Site.Title }} -{{ $pages := where .Site.RegularPages "Type" "posts" -}} +{{ $pages := .Scratch.Get "mainSectionPages" -}} {{- $pages = where $pages "Draft" "eq" false -}} {{- T "section.archiveCounter" (len $pages) }} {{ range $pages.GroupByPublishDate "2006" }} diff --git a/layouts/index.rss.xml b/layouts/index.rss.xml index 8b353881..56781f3d 100644 --- a/layouts/index.rss.xml +++ b/layouts/index.rss.xml @@ -36,7 +36,7 @@ {{ with .OutputFormats.Get "RSS" }} {{ printf "" .Permalink .MediaType | safeHTML }} {{ end }} - {{- range where .Site.RegularPages "Type" "posts" | first (.Site.Params.home.rss | default 10) -}} + {{- range .Scratch.Get "mainSectionPages" | first (.Site.Params.home.rss | default 10) -}} {{- $params := .Scratch.Get "params" -}} {{- if $params.password | or $params.hiddenFromRss }}{{ continue }}{{ end -}} {{- dict "Page" . "Site" .Site | partial "rss/item.html" -}} diff --git a/layouts/partials/init/global.html b/layouts/partials/init/global.html index 4a3319bb..79caa4a5 100644 --- a/layouts/partials/init/global.html +++ b/layouts/partials/init/global.html @@ -10,3 +10,7 @@ {{- $homeRelPermalink = strings.TrimSuffix "archives/" $homeRelPermalink -}} {{- $homeRelPermalink = strings.TrimSuffix "offline/" $homeRelPermalink -}} {{- .Scratch.Set "homeRelPermalink" $homeRelPermalink -}} + +{{- /* Set pages of main section */ -}} +{{- $pages := where .Site.RegularPages "Type" "posts" -}} +{{- .Scratch.Set "mainSectionPages" $pages -}} diff --git a/layouts/partials/init/index.html b/layouts/partials/init/index.html index 579312b3..345fe6f3 100644 --- a/layouts/partials/init/index.html +++ b/layouts/partials/init/index.html @@ -1,4 +1,4 @@ -{{- .Scratch.Set "version" "v0.3.1" -}} +{{- .Scratch.Set "version" "v0.3.2-RC" -}} {{- .Scratch.Set "params" (.Params | merge .Site.Params.page) -}} {{- .Scratch.Set "this" dict -}} diff --git a/layouts/partials/single/footer.html b/layouts/partials/single/footer.html index 8c36836d..66bd4c52 100644 --- a/layouts/partials/single/footer.html +++ b/layouts/partials/single/footer.html @@ -98,8 +98,13 @@
- {{- $prev := cond .Site.Params.navigationReverse .Next .Prev -}} - {{- $next := cond .Site.Params.navigationReverse .Prev .Next -}} + {{- $pages := .Scratch.Get "mainSectionPages" -}} + {{- $prev := $pages.Prev . -}} + {{- $next := $pages.Next . -}} + {{- if .Site.Params.navigationReverse -}} + {{- $prev = $pages.Next . -}} + {{- $next = $pages.Prev . -}} + {{- end -}} {{- with $prev -}}