From 04c9f041469835615641f7a01f92be896edae772 Mon Sep 17 00:00:00 2001 From: Christian Wolf Date: Thu, 4 Jan 2024 17:18:46 +0100 Subject: [PATCH] Create structure to create list of annoucnements --- .../2023/2023-12-31-winterfest-ds/index.md | 2 ++ .../2024-01-03-neuer-anfaengerkurs/index.md | 3 +++ content/page/aktuell/termine/_index.md | 2 +- themes/tsc_vfl/archetypes/news.md | 5 +++++ .../layouts/_default/announcements.html | 21 +++++++++++++++++++ .../partials/get-announcement-list.html | 11 ++++++++++ 6 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 themes/tsc_vfl/layouts/_default/announcements.html create mode 100644 themes/tsc_vfl/layouts/partials/get-announcement-list.html diff --git a/content/news/2023/2023-12-31-winterfest-ds/index.md b/content/news/2023/2023-12-31-winterfest-ds/index.md index 4f19d56..b8646a5 100644 --- a/content/news/2023/2023-12-31-winterfest-ds/index.md +++ b/content/news/2023/2023-12-31-winterfest-ds/index.md @@ -7,6 +7,8 @@ summary: |- draft: false # Die nächste Zeile anpassen, wenn das Thumbnail eingerichtet ist image: thumbnail.jpg +announcement: + date: 2024-01-27 --- Hi ihr Lieben, diff --git a/content/news/2024/2024-01-03-neuer-anfaengerkurs/index.md b/content/news/2024/2024-01-03-neuer-anfaengerkurs/index.md index c87e97f..27c8978 100644 --- a/content/news/2024/2024-01-03-neuer-anfaengerkurs/index.md +++ b/content/news/2024/2024-01-03-neuer-anfaengerkurs/index.md @@ -7,6 +7,9 @@ summary: |- draft: false # Die nächste Zeile anpassen, wenn das Thumbnail eingerichtet ist image: thumbnail.png +announcement: + date: 2024-01-10 + name: "Neuer Anfängerkurs" --- **Anmeldungen: Bitte schicken Sie eine Email an kontakt@tanzsportclub.vfl-sindelfingen.de** diff --git a/content/page/aktuell/termine/_index.md b/content/page/aktuell/termine/_index.md index ac130f2..3ae029c 100644 --- a/content/page/aktuell/termine/_index.md +++ b/content/page/aktuell/termine/_index.md @@ -2,7 +2,7 @@ title: "Termine" date: 2023-01-20T16:27:40+01:00 draft: false -# type: home +layout: announcements menu: main: weight: 1 diff --git a/themes/tsc_vfl/archetypes/news.md b/themes/tsc_vfl/archetypes/news.md index 37ef019..cebfb02 100644 --- a/themes/tsc_vfl/archetypes/news.md +++ b/themes/tsc_vfl/archetypes/news.md @@ -6,6 +6,11 @@ summary: |- draft: false # Die nächste Zeile anpassen, wenn das Thumbnail eingerichtet ist # image: thumbnail.jpg +# Wenn ein Blog-beitrag auch eine Terminankündigung sein soll, hier eintragen: +# announcement: +# date: 2023-11-11 +# # Optional kann man in der Terminerinnerung noch einen Kurztitel vergeben. +# name: "" --- Hier kommt der Text diff --git a/themes/tsc_vfl/layouts/_default/announcements.html b/themes/tsc_vfl/layouts/_default/announcements.html new file mode 100644 index 0000000..765de07 --- /dev/null +++ b/themes/tsc_vfl/layouts/_default/announcements.html @@ -0,0 +1,21 @@ +{{ define "main" }} + +

{{ .Title }}

+
+ {{ .Content }} +
+ {{ $announcements := partial "get-announcement-list" . }} + {{ range $announcements }} + {{ $urlBlogEntry := .RelPermalink}} +
+
+ {{ (time.AsTime .Params.announcement.date).Format "02.01.2006" }} + {{ with .Params.announcement.name }}{{.}}{{else}}{{.Title}}{{end}} +
+
+ {{ else }} + Aktuell gibt es keine angekündigten Termine. + {{ end }} +
+ {{ partial "totop" }} +{{ end }} diff --git a/themes/tsc_vfl/layouts/partials/get-announcement-list.html b/themes/tsc_vfl/layouts/partials/get-announcement-list.html new file mode 100644 index 0000000..4ba7e2d --- /dev/null +++ b/themes/tsc_vfl/layouts/partials/get-announcement-list.html @@ -0,0 +1,11 @@ +{{ $allNews := where .Site.RegularPages "Section" "==" "news" }} +{{ $announcements := where $allNews "Params.announcement" "ne" nil }} +{{ $announcements = where $announcements "Params.announcement.date" "ne" nil}} +{{ $futureAnnouncements := slice }} +{{ range $announcements }} + {{ if gt (time.AsTime .Params.announcement.date) now }} + {{ $futureAnnouncements = $futureAnnouncements | append . }} + {{ end }} +{{ end }} +{{ $announcements = sort $futureAnnouncements "Params.announcement.date" "asc" }} +{{ return $announcements }}