added featured articles option with distinct style

This commit is contained in:
Gabriele Musco 2021-04-13 23:30:34 +02:00
parent 4239ea5347
commit 13bb88e93a
No known key found for this signature in database
GPG key ID: 8539FD3454380B83
5 changed files with 75 additions and 10 deletions

View file

@ -2,7 +2,37 @@
{{/* get all the pages that are regular posts and not pages */}}
{{ $postsDir := .Site.Params.Posts | default (slice "posts" "post") }}
{{ $postsList := where .Site.RegularPages "Section" "in" $postsDir }}
{{ $allPostsList := where .Site.RegularPages "Section" "in" $postsDir }}
{{ $featuredPostsList := slice }}
{{ $postsList := $allPostsList }}
{{ if .Site.Params.enableFeatured | default false }}
{{ $featuredPostsList = where $allPostsList "Params.featured" true }}
{{ $postsList = union (where $allPostsList "Params.featured" false) (where $allPostsList "Params.featured" nil) }}
{{ end }}
<div class="featured postlist gridView">
{{ range $featuredPostsList }}
<a class="featuredCardLink" href="{{ .Permalink }}">
<article class="featuredCard {{ if .Site.Params.discreteCards }}discrete{{ end }}"
style="background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 59%, rgba(0, 0, 0, 0.7) 100%), url('{{ .Params.Image }}');">
<div class="contentArea">
<h2>{{ .Title }}</h2>
<p class="date">
<span title="Date"></span>
{{ .Date.Format "2006-01-02" }}
{{ if .Params.tags }}
<br />
<span title="Tags"></span>
{{ range .Params.tags }}
#{{ . }}
{{ end }}
{{ end }}
</p>
</div>
</article>
</a>
{{ end }}
</div>
{{/* pagination */}}
<div class="postlist {{ if .Site.Params.gridView }}gridView{{ end }}" id="postlist">