layouts/partials/featured.html: Wire up features

This gets three random posts and uses the first for the top feature
and the second and third for the two smaller features.
This commit is contained in:
Alan Orth 2020-12-07 23:16:48 +02:00
parent 48f56114be
commit eb65845f60
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9
1 changed files with 12 additions and 4 deletions

View File

@ -1,15 +1,22 @@
{{ $dateFormat := default "Mon Jan 2, 2006" (index .Site.Params "date_format") }}
{{/* get three random posts: 1 for large feature, 2 for small features */}}
{{ range $index, $element := first 3 (where .Site.RegularPages "Section" "in" .Site.Params.mainSections) | shuffle }}
{{ if eq $index 0 }}
<div class="p-4 p-md-5 mb-4 text-white rounded bg-dark">
<div class="col-md-6 px-0">
<h1 class="display-4 font-italic">Title of a longer featured blog post</h1>
<p class="lead my-3">Multiple lines of text that form the lede, informing new readers quickly and efficiently about whats most interesting in this posts contents.</p>
<p class="lead mb-0"><a href="#" class="text-white fw-bold">Continue reading...</a></p>
<h1 class="display-4 font-italic">{{ .Title }}</h1>
<p class="lead my-3">{{ substr .Description 0 110 }}</p>
<p class="lead mb-0"><a href="{{ .Permalink }}" class="text-white fw-bold">Continue reading...</a></p>
</div>
</div>
{{ end }}
{{ if eq $index 1 }}
<div class="row mb-2">
{{ range first 2 (where .Site.RegularPages "Section" "in" .Site.Params.mainSections) | shuffle }}
{{ end }}
{{ if or (eq $index 1) (eq $index 2) }}
<div class="col-md-6">
<div class="row g-0 border rounded overflow-hidden flex-md-row mb-4 shadow-sm h-md-300 position-relative">
<div class="col p-4 d-flex flex-column position-static">
@ -40,6 +47,7 @@
</div>
</div>
{{ end }}
{{ end }}
</div>
{{- /* vim: set ts=2 sw=2 et: */}}