refactor: centralize pagination logic (#1227)

* refactor: centralize pagination logic into a new helper partial used for page titles and index display

* fix: list.html does not exclude hidden pages

* refactor: Simplify title generation logic
This commit is contained in:
Jimmy
2026-01-25 17:54:13 +01:00
committed by GitHub
parent 12daa8c9fc
commit 9add062300
4 changed files with 49 additions and 42 deletions
+23
View File
@@ -0,0 +1,23 @@
{{- $pages := "" -}}
{{- if .IsHome -}}
{{ $pages = where .Site.RegularPages "Section" "in" .Site.Params.mainSections }}
{{ $pages = where $pages "Params.hidden" "!=" true }}
{{- else if eq .Kind "term" -}}
{{ $pages = where .Pages "Params.hidden" "!=" true }}
{{- else if or (eq .Kind "section") (eq .Kind "taxonomy") -}}
{{ $subsections := .Sections }}
{{ $pages = .Pages | complement $subsections }}
{{ $pages = where $pages "Params.hidden" "!=" true }}
{{- if eq (len $pages) 0 -}}
{{/* See complete logic in list.html */}}
{{- $pages = $subsections -}}
{{- end -}}
{{- end -}}
{{- if $pages -}}
{{ $pages = .Paginate $pages }}
{{- end -}}
{{ return $pages }}