From ab14f2f2753e33063f57d9cf664b81b22c28affe Mon Sep 17 00:00:00 2001 From: Digitalcraftsman Date: Fri, 11 Sep 2020 20:36:58 +0200 Subject: [PATCH] Adapt theme to be compatible with hugoBasicExample _default/{archives,list}.html utilize .site.Params.mainSections This flexible option let's users decide what content pages they want to display in the archive and on the homepage. By default, Hugo adds content types with the most content files as a good heuristic. Can be overwritten at any time in the config file. Signed-off-by: Aditya Telange <21258296+adityatelange@users.noreply.github.com> --- layouts/_default/archives.html | 4 ++-- layouts/_default/list.html | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/layouts/_default/archives.html b/layouts/_default/archives.html index 4a7b1220..aa419eaa 100644 --- a/layouts/_default/archives.html +++ b/layouts/_default/archives.html @@ -2,8 +2,8 @@
- - {{ range .Site.RegularPages.GroupByPublishDate "2006" }} + {{ $pages := where site.RegularPages "Type" "in" site.Params.mainSections }} + {{ range $pages.GroupByPublishDate "2006" }} {{ if ne .Key "0001" }}

{{ replace .Key "0001" "" }}

diff --git a/layouts/_default/list.html b/layouts/_default/list.html index c00e02f9..ecb3f8d0 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -4,20 +4,20 @@ {{- partial "indexProfile.html" . }} {{else}} {{/* if not profileMode */}} -{{ $isntDefault := not (or (eq (trim $.Site.Params.contentTypeName " ") "posts") (eq (trim $.Site.Params.contentTypeName " ") "")) }} -{{ $contentTypeName := cond $isntDefault (string $.Site.Params.contentTypeName) "posts" }} - -{{ $PageContext := . }} -{{ if .IsHome }} -{{ $PageContext = .Site }} -{{else}} -{{- if .Title }} +{{- if not .IsHome | and .Title }} {{ end }} -{{ end }} -{{ $paginator := .Paginate (where $PageContext.RegularPages "Type" $contentTypeName) }} + + +{{ $pages := .RegularPages }} + +{{ if .IsHome }} +{{ $pages = where site.RegularPages "Type" "in" site.Params.mainSections }} +{{end}} + +{{ $paginator := .Paginate $pages }} {{- range $index, $page := $paginator.Pages }}