featured articles only shown in first page of home page

This commit is contained in:
Gabriele Musco 2021-04-14 13:00:42 +02:00
parent efaaecc82f
commit bfa66798b3
No known key found for this signature in database
GPG Key ID: 8539FD3454380B83
1 changed files with 5 additions and 2 deletions

View File

@ -5,15 +5,18 @@
{{ $allPostsList := where .Site.RegularPages "Section" "in" $postsDir }} {{ $allPostsList := where .Site.RegularPages "Section" "in" $postsDir }}
{{ $featuredPostsList := slice }} {{ $featuredPostsList := slice }}
{{ $postsList := $allPostsList }} {{ $postsList := $allPostsList }}
{{ $pagination := (.Paginate $postsList).Pages }}
{{ if .Site.Params.enableFeatured | default false }} {{ if .Site.Params.enableFeatured | default false }}
{{ $featuredPostsList = where $allPostsList "Params.featured" true }} {{ $featuredPostsList = where $allPostsList "Params.featured" true }}
{{ $postsList = union (where $allPostsList "Params.featured" false) (where $allPostsList "Params.featured" nil) }} {{ $postsList = union (where $allPostsList "Params.featured" false) (where $allPostsList "Params.featured" nil) }}
{{ if eq .Paginator.PageNumber 1 }}
{{- partial "featured_articles.html" $featuredPostsList -}} {{- partial "featured_articles.html" $featuredPostsList -}}
{{ end }} {{ end }}
{{ end }}
{{/* pagination */}} {{/* pagination */}}
<div class="postlist {{ if .Site.Params.gridView }}gridView{{ end }}" id="postlist"> <div class="postlist {{ if .Site.Params.gridView }}gridView{{ end }}" id="postlist">
{{ range (.Paginate $postsList).Pages }} {{ range $pagination }}
<article class="card postlistitem {{ if .Site.Params.discreteCards }}discrete{{ end }}"> <article class="card postlistitem {{ if .Site.Params.discreteCards }}discrete{{ end }}">
<div> <div>
<h2> <h2>