only show upcoming events section if there are upcoming events

This commit is contained in:
rra 2022-09-29 16:03:36 +02:00
parent 32953f38fc
commit 58efb45a8c

View File

@ -3,26 +3,36 @@
<section class='entries'>
{{ $now := (now.Format "060102" ) }}
<div class="upcoming event-list">
<div class='tape-label'><span>upcoming events</span></div>
{{ range .Pages }}
{{ $upcoming := slice }}
{{ $past := slice}}
{{ range .Pages }}
{{ $t := (substr .Params.event_end 2 8) }}
{{ $time := ( replace $t "-" "") }}
{{ if ge $time $now }}
{{- partial "event_list_item.html" . -}}
{{ $upcoming = $upcoming | append . }}
{{ else if gt $now $time }}
{{ $past = $past | append . }}
{{ end }}
{{ end }}
</div>
{{ with $upcoming }}
<div class="upcoming event-list">
<div class='tape-label'><span>upcoming events</span></div>
{{ range $upcoming}}
{{- partial "event_list_item.html" . -}}
{{end}}
</div>
{{end}}
{{ with $past }}
<div class="past event-list">
<div class='tape-label'><span>past events</span></div>
{{ range .Pages }}
{{ $t := (substr .Params.event_end 2 8) }}
{{ $time := ( replace $t "-" "") }}
{{ if gt $now $time }}
{{- partial "event_list_item.html" . -}}
{{ end }}
{{ range $past }}
{{- partial "event_list_item.html" . -}}
{{ end }}
</div>
{{ end }}
</section>
</main>