fix all pages query issues in: list, archives, newsletter section, post_nav_links

This commit is contained in:
Reorx 2022-09-08 00:25:50 +08:00
parent 462835f1d8
commit d9c228117b
4 changed files with 14 additions and 7 deletions

View File

@ -9,12 +9,13 @@
{{- end }} {{- end }}
</header> </header>
{{/* get pages from the current page's section */}}
{{/* in this way, archives.html could be used for section archives other than the only one archives of the whole site */}}
{{- $sections := site.Params.mainSections }} {{- $sections := site.Params.mainSections }}
{{/* with the follow condition, archives.html could be used for section archives other than the only one archives of the whole site */}}
{{- if .Section }} {{- if .Section }}
{{- $sections = .Section}} {{- $sections = slice .Section }}
{{- end }} {{- end }}
{{- $pages := where site.AllPages "Type" "in" $sections }} {{- $pages := where (where site.RegularPages "Section" "in" $sections) "Params.hidden" "!=" true }}
{{- range $pages.GroupByPublishDate "2006" }} {{- range $pages.GroupByPublishDate "2006" }}
{{- if ne .Key "0001" }} {{- if ne .Key "0001" }}

View File

@ -32,6 +32,7 @@
{{- $pages := .Pages }} {{- $pages := .Pages }}
{{- if .IsHome }} {{- if .IsHome }}
{{/* get all regular pages instead of pages in a section */}}
{{- $pages = where site.RegularPages "Section" "in" site.Params.mainSections }} {{- $pages = where site.RegularPages "Section" "in" site.Params.mainSections }}
{{- end }} {{- end }}
{{- $pages = where $pages "Params.hidden" "!=" true }} {{- $pages = where $pages "Params.hidden" "!=" true }}

View File

@ -13,12 +13,10 @@
{{- partial "newsletter_sub_form.html"}} {{- partial "newsletter_sub_form.html"}}
</div> </div>
{{- $pages := where .Pages "Params.hidden" "!=" true }}
<h2>最近更新</h2> <h2>最近更新</h2>
<div class="list"> <div class="list">
{{- range first 5 $pages }} {{- range first 5 (where .Pages "Params.hidden" "!=" true) }}
<div class="item"> <div class="item">
<div class="date"> <div class="date">
{{- if not .Date.IsZero -}} {{- if not .Date.IsZero -}}

View File

@ -1,4 +1,11 @@
{{- $pages := where site.RegularPages "Type" "in" site.Params.mainSections }} {{/* get pages from the current page's section */}}
{{- $sections := site.Params.mainSections }}
{{- if .Section }}
{{- $sections = slice .Section }}
{{- end }}
{{ $sections }}
{{- $pages := where (where site.RegularPages "Section" "in" $sections) "Params.hidden" "!=" true }}
{{- if and (gt (len $pages) 1) (in $pages . ) }} {{- if and (gt (len $pages) 1) (in $pages . ) }}
<nav class="paginav"> <nav class="paginav">
{{- with $pages.Next . }} {{- with $pages.Next . }}