From b0114b9bef7132494666aa4e7ee11276f11d6452 Mon Sep 17 00:00:00 2001 From: David Eisinger Date: Thu, 9 Jan 2025 21:38:46 -0500 Subject: [PATCH] Filter posts by date --- themes/v2/layouts/archive/single.html | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/themes/v2/layouts/archive/single.html b/themes/v2/layouts/archive/single.html index 836cfef..6d5c48d 100644 --- a/themes/v2/layouts/archive/single.html +++ b/themes/v2/layouts/archive/single.html @@ -1,11 +1,19 @@ {{ define "main" }} + {{ $sd := .Params.start_date }} + {{ $ed := .Params.end_date }} +
- {{ time.Format "January 2006" .Params.start_date }} – - {{ time.Format "January 2006" .Params.end_date}} + {{ time.Format "January 2006" $sd }} – {{ time.Format "January 2006" $ed }}
{{ range (sort (.Site.RegularPages.RelatedTo (keyVals "tags" "dispatch")) "Date" "asc") }} - {{ $page := . }} + {{ if lt (time.Format "2006-01-02" .Date) (time.Format "2006-01-02" $sd) }} + {{ continue }} + {{ end }} + + {{ if gt (time.Format "2006-01-02" .Date) (time.Format "2006-01-02" $ed) }} + {{ continue }} + {{ end }}