From eb65845f6051068df3af2466a887b8479c8c9d55 Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Mon, 7 Dec 2020 23:16:48 +0200 Subject: [PATCH] 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. --- layouts/partials/featured.html | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/layouts/partials/featured.html b/layouts/partials/featured.html index 7947851..2a94f52 100644 --- a/layouts/partials/featured.html +++ b/layouts/partials/featured.html @@ -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 }}
-

Title of a longer featured blog post

-

Multiple lines of text that form the lede, informing new readers quickly and efficiently about what’s most interesting in this post’s contents.

-

Continue reading...

+

{{ .Title }}

+

{{ substr .Description 0 110 }}

+

Continue reading...

+{{ end }} +{{ if eq $index 1 }}
-{{ range first 2 (where .Site.RegularPages "Section" "in" .Site.Params.mainSections) | shuffle }} +{{ end }} + +{{ if or (eq $index 1) (eq $index 2) }}
@@ -40,6 +47,7 @@
{{ end }} +{{ end }}
{{- /* vim: set ts=2 sw=2 et: */}}