Create structure to create list of annoucnements
This commit is contained in:
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 }}
|
||||
Reference in New Issue
Block a user