This repository was archived by the owner on Jul 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathpast.html
More file actions
45 lines (42 loc) · 1.92 KB
/
past.html
File metadata and controls
45 lines (42 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{{/* Scan through a range of years and look in data/events for events during these years.
If found, store year in "active_years" scratch in order to get back to that year later.
Also save the event name under scratch with the ID of the scratch equal to the year number.
Chomping .year has the nice effect of turning an int into string. */}}
{{- range seq 2009 2020 -}}
{{- $r_year := . -}}
{{- range $.Site.Data.events -}}
{{- if .startdate -}}
{{- $my_year := string ((dateFormat "2006" .enddate )) -}}
{{- if and (eq $my_year (string $r_year)) ( lt (dateFormat "2006-01-02" .enddate) (dateFormat "2006-01-02" (dateFormat "2006-01-02" now))) -}}
{{- $.Scratch.SetInMap "active_years" (print (chomp $my_year)) (print (chomp $my_year)) -}}
{{- $.Scratch.SetInMap (print (chomp $my_year)) .enddate (.name) -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
<div class = "row">
<div class = "col-md-12">
<h2>Past</h2>
</div>
</div>
<div class = "row">
{{/* Now scan through all the years that were marked as active in order to print the headline */}}
{{- range ($.Scratch.GetSortedMapValues "active_years") -}}
<div class = "col-md-6 col-lg-3 events-page-col">
<h4 class="events-page-months">{{ . }}</h4>
{{- $.Scratch.Set "the_year" . -}}
<br/>
{{/* Finally, scan throug the scratch with the ID of that year and print all the events sorted by startdate
Chomping here in order to convert int to string */}}
{{- range sort $.Site.Data.events "startdate" -}}
{{- if .startdate -}}
{{- if eq ( print (chomp (dateFormat "2006" .startdate))) (print (chomp ($.Scratch.Get "the_year"))) -}}
{{- $.Scratch.Set "citydisplay" .city -}}
<a href="{{ (printf "events/%s" .name) | absURL }}" class = "events-page-event">{{ $.Scratch.Get "citydisplay" }}</a>
<br/>
{{- end -}}
{{- end -}}
{{- end -}}
</div>
{{- end -}}
</div>