refactor: use .Params.mainSections to filter posts

It's recommended by Hugo's official doc: https://gohugo.io/functions/where/#mainsections
This commit is contained in:
Jimmy Cai
2020-09-06 13:15:38 +02:00
parent 47fb5af201
commit e176e29811
5 changed files with 16 additions and 17 deletions
+3 -3
View File
@@ -4,9 +4,9 @@
</div>
<h1 class="widget-title">Archive</h1>
{{ $v1 := where .Site.RegularPages "Section" "post" }}
{{ $v2 := where .Site.RegularPages "Params.hidden" "!=" true }}
{{ $filtered := $v1 | intersect $v2 }}
{{ $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }}
{{ $notHidden := where .Site.RegularPages "Params.hidden" "!=" true }}
{{ $filtered := ($pages | intersect $notHidden) }}
{{ $archive := $filtered.GroupByDate "2006" }}
{{ range first .Site.Params.widgets.archive.limit ($archive) }}