Commit effc09ee authored by Laura Kalbag's avatar Laura Kalbag

Only show upcoming events if there are any

Closes #82
parent 842c12da
......@@ -3,25 +3,31 @@
<h1>{{ .Title }}</h1>
{{ .Content }}
<h2>Upcoming Events</h2>
<ul class="events-list future">
{{ range where .Pages.ByDate "Section" .Section }}
{{ if ge .Date now }}
<li class='h-event'>
<time datetime='{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}' class='dt-start'>
{{- .Date.Format "2" | humanize }} {{ .Date.Format "January, 2006" -}}
</time>
<h3 class='p-name'>
{{- .Title }} in {{ .Params.eventCity }}, {{ .Params.eventCountry }}
</h3>
<p class="summary p-summary">
{{- .Content }}
</p>
<p><a href="{{ .Params.eventURL }}" class='event-link u-url'>Learn more about {{ .Title }}.</a></p>
</li>
{{/* Only show the upcoming events section if there are any upcoming events. */}}
{{ $posts := (where (where .Pages.ByDate "Section" .Section) "Date" "gt" now ) }}
{{ $postCount := len $posts }}
{{ if gt $postCount 0}}
<h2>Upcoming Events</h2>
<ul class="events-list future">
{{ range where .Pages.ByDate "Section" .Section }}
{{ if ge .Date now }}
<li class='h-event'>
<time datetime='{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}' class='dt-start'>
{{- .Date.Format "2" | humanize }} {{ .Date.Format "January, 2006" -}}
</time>
<h3 class='p-name'>
{{- .Title }} in {{ .Params.eventCity }}, {{ .Params.eventCountry }}
</h3>
<p class="summary p-summary">
{{- .Content }}
</p>
<p><a href="{{ .Params.eventURL }}" class='event-link u-url'>Learn more about {{ .Title }}.</a></p>
</li>
{{ end }}
{{ end }}
</ul>
{{ end }}
</ul>
<h2>Past Events</h2>
<ul class="events-list past">
{{ range where .Pages.ByDate.Reverse "Section" .Section }}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment