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:
@ -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">
|
||||
|
Reference in New Issue
Block a user