layouts: Make featured posts configurable

For now it gets the first three posts with "featured: true" in their
frontmatter and displays them in a random order (so no control over
the placement of large feature or two smaller features).

TODO: gracefully handle the case where there are no pages with the
"featured: true" frontmatter so new users don't see a super weird
and broken front page.
This commit is contained in:
2020-12-28 10:03:41 +02:00
parent 40c902ae8a
commit f28cf4615c
3 changed files with 3 additions and 95 deletions

View File

@ -1,6 +1,6 @@
{{ $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 }}
{{/* get three random featured posts: 1 for large feature, 2 for small features */}}
{{ range $index, $element := first 3 (where .Site.RegularPages "Params.featured" true) | shuffle }}
{{ if eq $index 0 }}
<div class="p-4 p-md-5 mb-4 text-white rounded bg-dark">