Create structure to create list of annoucnements
This commit is contained in:
parent
28e9d32e2c
commit
04c9f04146
@ -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,
|
||||
|
@ -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**
|
||||
|
@ -2,7 +2,7 @@
|
||||
title: "Termine"
|
||||
date: 2023-01-20T16:27:40+01:00
|
||||
draft: false
|
||||
# type: home
|
||||
layout: announcements
|
||||
menu:
|
||||
main:
|
||||
weight: 1
|
||||
|
@ -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
|
||||
|
21
themes/tsc_vfl/layouts/_default/announcements.html
Normal file
21
themes/tsc_vfl/layouts/_default/announcements.html
Normal file
@ -0,0 +1,21 @@
|
||||
{{ define "main" }}
|
||||
<a name="top">
|
||||
<h1>{{ .Title }}</h1>
|
||||
</a>
|
||||
{{ .Content }}
|
||||
<div class="announcement-list">
|
||||
{{ $announcements := partial "get-announcement-list" . }}
|
||||
{{ range $announcements }}
|
||||
{{ $urlBlogEntry := .RelPermalink}}
|
||||
<div class="blog-entry">
|
||||
<div class="header">
|
||||
{{ (time.AsTime .Params.announcement.date).Format "02.01.2006" }}
|
||||
<a href="{{ $urlBlogEntry }}">{{ with .Params.announcement.name }}{{.}}{{else}}{{.Title}}{{end}}</a>
|
||||
</div>
|
||||
</div>
|
||||
{{ else }}
|
||||
Aktuell gibt es keine angekündigten Termine.
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ partial "totop" }}
|
||||
{{ end }}
|
11
themes/tsc_vfl/layouts/partials/get-announcement-list.html
Normal file
11
themes/tsc_vfl/layouts/partials/get-announcement-list.html
Normal file
@ -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 }}
|
Loading…
Reference in New Issue
Block a user