Skip to content

Commit dc14221

Browse files
authored
Add upcoming events (#141)
* add upcoming-events section, displays first 3 upcoming items with the "meetup" tag * update meetup-date to event-date, and sort between past events and upcoming events using events tag * add styling to have icons in place of bullet points * add icons for posts, meetups, and events * fix upcoming and past-events section * remove unneeded styling * update icons to respond to light/dark mode * add back in the icons * update styling to reflect requested changes
1 parent 7546415 commit dc14221

File tree

5 files changed

+154
-64
lines changed

5 files changed

+154
-64
lines changed

assets/sass/_custom.sass

+32-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// override flex and use grid to layout title and subtitle
2-
32
.nav_brand
43
&.nav_item
54
display: grid
@@ -53,6 +52,38 @@ div.subscribe
5352
margin-right: 0.5rem
5453
margin-left: 0.25rem
5554

55+
.sidebar_list
56+
list-style: none
57+
padding-left: 0
58+
59+
li
60+
position: relative
61+
display: flex
62+
align-items: center
63+
margin: 0
64+
65+
.icon
66+
width: 1.125rem
67+
height: 1.125rem
68+
margin-right: 0.5rem
69+
margin-bottom: auto
70+
margin-top: 0.25rem //this margin-top of 4px is necessary to align the icon with the text
71+
72+
.event_list
73+
list-style: none
74+
padding-left: 0
75+
76+
li
77+
position: relative
78+
display: flex
79+
align-items: center
80+
81+
.icon
82+
width: 1.125rem
83+
height: 1.125rem
84+
margin-right: 0.5rem
85+
margin-bottom: auto
86+
margin-top: 0.25rem //this margin-top of 4px is necessary to align the icon with the text
5687

5788
.half-width
5889
max-width: 500px

layouts/partials/sidebar.html

+119-63
Original file line numberDiff line numberDiff line change
@@ -5,95 +5,148 @@
55
{{ partial "search/widget" . }}
66
{{- $introDescription := $s.introDescription }}
77
{{- with .Params.introDescription }}
8-
{{- $introDescription = . }}
8+
{{- $introDescription = . }}
99
{{- end }}
1010
{{- if $introDescription }}
11-
{{- $author := $s.Author }}
12-
{{- $showAuthorPhoto := false }}
13-
{{- $fullAuthor := reflect.IsMap $author }}
14-
{{- if $fullAuthor }}
15-
{{- if $author.photo }}
16-
{{- $showAuthorPhoto = true }}
17-
{{- end }}
18-
{{- end }}
19-
{{- if $showAuthorPhoto }}
20-
<div class="author_header">
21-
<img src="{{ relURL $author.photo }}" alt="{{ $author.name }} photo">
22-
<h2>{{ $author.name }}</h2>
23-
</div>
24-
{{- else }}
25-
<h2>{{ if $fullAuthor }}{{ $author.name }}{{ else }}{{ $author }}{{ end }}</h2>
26-
{{- end }}
27-
<div class="author_bio">
28-
{{ markdownify $introDescription }}
29-
</div>
30-
{{- if ( ne $s.introURL false ) }}
31-
{{- $r := T "read_more" }}
32-
<a href='{{ relLangURL (default "about/" $s.introURL) }}' class="button mt-1" role="button" title='{{ $r }}'>{{ $r }}</a>
33-
{{- end }}
11+
{{- $author := $s.Author }}
12+
{{- $showAuthorPhoto := false }}
13+
{{- $fullAuthor := reflect.IsMap $author }}
14+
{{- if $fullAuthor }}
15+
{{- if $author.photo }}
16+
{{- $showAuthorPhoto = true }}
17+
{{- end }}
18+
{{- end }}
19+
{{- if $showAuthorPhoto }}
20+
<div class="author_header">
21+
<img src="{{ relURL $author.photo }}" alt="{{ $author.name }} photo">
22+
<h2>{{ $author.name }}</h2>
23+
</div>
24+
{{- else }}
25+
<h2>{{ if $fullAuthor }}{{ $author.name }}{{ else }}{{ $author }}{{ end }}</h2>
26+
{{- end }}
27+
<div class="author_bio">
28+
{{ markdownify $introDescription }}
29+
</div>
30+
{{- if ( ne $s.introURL false ) }}
31+
{{- $r := T "read_more" }}
32+
<a href='{{ relLangURL (default "about/" $s.introURL) }}' class="button mt-1" role="button" title='{{ $r }}'>{{ $r
33+
}}</a>
34+
{{- end }}
3435
{{- end }}
3536

3637
{{ if .Site.Params.sidebardisclaimer }}
37-
<div class="sidebardisclaimer">
38-
<h2 class="mt-4">Disclaimer</h2>
39-
{{ .Site.Params.disclaimerText }}
40-
</div>
38+
<div class="sidebardisclaimer">
39+
<h2 class="mt-4">Disclaimer</h2>
40+
{{ .Site.Params.disclaimerText }}
41+
</div>
4142
{{ end }}
4243

4344
{{- $relatedInSidebar := true }}
4445
{{- if eq $s.showRelatedInSidebar false }}
45-
{{ $relatedInSidebar = false }}
46+
{{ $relatedInSidebar = false }}
4647
{{- end }}
4748
{{ if (and ($relatedInSidebar) (isset .Params "series") ) }}
48-
{{$related := where .Site.RegularPages ".Params.series" "eq" .Params.series }}
49-
<h2 class="mt-4">{{ T "series_posts" }}</h2>
50-
<ul>
51-
{{ range $related }}
52-
<li>
53-
<a href="{{ .RelPermalink }}" class="nav-link" title="{{ .Title }}">{{ .Title | markdownify }}</a>
54-
</li>
55-
{{ end }}
56-
</ul>
49+
{{$related := where .Site.RegularPages ".Params.series" "eq" .Params.series }}
50+
<h2 class="mt-4">{{ T "series_posts" }}</h2>
51+
<ul>
52+
{{ range $related }}
53+
<li>
54+
<a href="{{ .RelPermalink }}" class="nav-link" title="{{ .Title }}">{{ .Title | markdownify }}</a>
55+
</li>
56+
{{ end }}
57+
</ul>
5758
{{ end }}
5859

5960
{{- $posts := where .Site.RegularPages "Type" "in" $s.mainSections }}
6061
{{- $featured := default 8 $s.numberOfFeaturedPosts }}
6162
{{- $featuredPosts := first $featured (where $posts "Params.featured" true)}}
6263
{{- with $featuredPosts }}
6364
<h2 class="mt-4">{{ T "featured_posts" }}</h2>
64-
<ul>
65+
<ul class="sidebar_list">
6566
{{- range . }}
6667
<li>
68+
<img class="icon" src="/icons/book.svg" alt="Post Icon">
6769
<a href="{{ .RelPermalink }}" class="nav-link" title="{{ .Title }}">{{ .Title | markdownify }}</a>
6870
</li>
6971
{{- end }}
7072
</ul>
7173
{{- end }}
74+
75+
<h2 class="mt-4">Upcoming Events</h2>
76+
<ul class="event_list" style="list-style-type: none;">
77+
{{- $allEvents := site.Taxonomies.tags.event }}
78+
{{- $upcomingEvents := slice }}
79+
80+
{{- range $allEvents }}
81+
{{- if .Params.event_date }}
82+
{{- $eventTime := .Params.event_date | time }}
83+
{{- if gt $eventTime time.Now }}
84+
{{- $upcomingEvents = $upcomingEvents | append . }}
85+
{{- end }}
86+
{{- end }}
87+
{{- end }}
88+
89+
{{- range first 5 $upcomingEvents }}
90+
{{- $isMeetup := false }}
91+
{{- range .Params.tags }}
92+
{{- if eq . "meetup" }}
93+
{{- $isMeetup = true }}
94+
{{- end }}
95+
{{- end }}
96+
<li {{ if $isMeetup }} class="meetup" {{ end }}>
97+
<img class="icon" {{ if $isMeetup }} src="/icons/group.svg" alt="Meetup Icon" {{else}} src="/icons/calendar.svg"
98+
alt="Event Icon" {{ end }}>
99+
<a href="{{ .RelPermalink }}" class="nav-link" title="{{ .Title }}">
100+
{{ .Title | markdownify }}
101+
{{ if .Params.event_date }} ({{ time.Format "Jan 2006" .Params.event_date }}){{ end }}
102+
</a>
103+
</li>
104+
{{- end }}
105+
</ul>
106+
72107
<h2 class="mt-4">{{ T "recent_posts" }}</h2>
73-
<ul class="flex-column">
108+
<ul class="sidebar_list" style="list-style-type: none;">
74109
{{- $recent := default 8 $s.numberOfRecentPosts }}
75110
{{- range first $recent ($posts | complement $featuredPosts) }}
76111
<li>
112+
<img class="icon" src="/icons/book.svg" alt="Post Icon">
77113
<a href="{{ .RelPermalink }}" class="nav-link" title="{{ .Title }}">{{ .Title | markdownify }}</a>
78114
</li>
79115
{{- end }}
80116
</ul>
81117

82-
<h2 class="mt-4">Meetups</h2>
83-
<ul class="flex-column">
84-
{{- range first 3 (site.Taxonomies.tags.Get "meetup") }}
85-
<li>
118+
<h2 class="mt-4">Past Events</h2>
119+
<ul class="event_list" style="list-style-type: none;">
120+
{{- $allEvents := site.Taxonomies.tags.event }}
121+
{{- $pastEvents := slice }}
122+
123+
{{- range $allEvents }}
124+
{{- if .Params.event_date }}
125+
{{- $eventTime := .Params.event_date | time }}
126+
{{- if lt $eventTime time.Now }}
127+
{{- $pastEvents = $pastEvents | append . }}
128+
{{- end }}
129+
{{- end }}
130+
{{- end }}
131+
132+
{{- range first 3 $pastEvents }}
133+
{{- $isMeetup := false }}
134+
{{- range .Params.tags }}
135+
{{- if eq . "meetup" }}
136+
{{- $isMeetup = true }}
137+
{{- end }}
138+
{{- end }}
139+
<li {{ if $isMeetup }} class="meetup" {{ end }}>
140+
<img class="icon" {{ if $isMeetup }} src="/icons/group.svg" alt="Meetup Icon" {{else}} src="/icons/calendar.svg"
141+
alt="Event Icon" {{ end }}>
86142
<a href="{{ .RelPermalink }}" class="nav-link" title="{{ .Title }}">
87-
88-
{{ if .Params.meetup_date }}
89-
{{ $meetupTime := .Params.meetup_date | time }}
90-
{{ if lt time.Now $meetupTime }}<b>[Upcoming]</b>{{end}}
91-
{{ end}}
92-
{{ .Title | markdownify }} {{ if .Params.meetup_date }} ({{ time.Format "Jan 2006" .Params.meetup_date }}){{ end }}
143+
{{ .Title | markdownify }}
144+
{{ if .Params.event_date }} ({{ time.Format "Jan 2006" .Params.event_date }}){{ end }}
93145
</a>
94146
</li>
95147
{{- end }}
96148
</ul>
149+
97150
<p><a href='{{ ref . "/tags/meetup" }}'>Browse all meetups.</a></p>
98151

99152
{{- $tagsLimit := (default 100 $s.numberOfTagsShown) }}
@@ -105,7 +158,8 @@ <h2 class="mt-4 taxonomy" id="{{ $key }}-section">{{ T $key }}</h2>
105158
{{- $onPageTags := $.Page.Params.tags }}
106159
{{- $slicedTags := ($value.ByCount | first $tagsLimit) }}
107160
{{- range $slicedTags }}
108-
<a href='{{ relLangURL $key }}/{{ (replace .Name "#" "%23") | urlize }}/' class="post_tag button button_translucent" title="{{ .Name }}">
161+
<a href='{{ relLangURL $key }}/{{ (replace .Name "#" "%23") | urlize }}/'
162+
class="post_tag button button_translucent" title="{{ .Name }}">
109163
{{ .Name }}
110164
<span class="button_tally">{{ .Count }}</span>
111165
</a>
@@ -118,16 +172,18 @@ <h2 class="mt-4 taxonomy" id="{{ $key }}-section">{{ T $key }}</h2>
118172
<div class="tags_list">
119173
{{- range $value.Alphabetical }}
120174
{{ $tagsInfo.Add "tagsInfo" (slice .Name .Count)}}
121-
<a href='{{ relLangURL $key }}/{{ (replace .Name "#" "%23") | urlize }}/' class=" post_tag button button_translucent" data-position={{ .Count }} title="{{ .Name }}">
175+
<a href='{{ relLangURL $key }}/{{ (replace .Name "#" "%23") | urlize }}/'
176+
class=" post_tag button button_translucent" data-position={{ .Count }} title="{{ .Name }}">
122177
{{- .Name -}}
123178
<span class="button_tally">{{ .Count }}</span>
124179
</a>
125180
{{ end }}
126-
<div class="tags_sort"><span title="sort alphabetically">[A~Z]</span><span title="sort by count">[0~9]</span>
181+
<div class="tags_sort"><span title="sort alphabetically">[A~Z]</span><span
182+
title="sort by count">[0~9]</span>
127183
</div>
128184
<span class="tags_hide"><svg class="icon">
129-
<use xlink:href="#closeme"></use>
130-
</svg></span>
185+
<use xlink:href="#closeme"></use>
186+
</svg></span>
131187
</div>
132188
</div>
133189
{{- end }}
@@ -139,17 +195,17 @@ <h2 class="mt-4 taxonomy" id="{{ $key }}-section">{{ T $key }}</h2>
139195
<div class="subscribe">
140196
<h2>Subscribe via RSS</h2>
141197
<ul>
142-
{{/* provide an RSS link for each section */}}
143-
{{- range .Site.Sections -}}
198+
{{/* provide an RSS link for each section */}}
199+
{{- range .Site.Sections -}}
144200
{{- $sectionTitle := .Title -}}
145201
{{- with .OutputFormats.Get "rss" -}}
146-
<li><a href="{{ .RelPermalink }}">{{ $sectionTitle }}</a></li>
202+
<li><a href="{{ .RelPermalink }}">{{ $sectionTitle }}</a></li>
203+
{{- end -}}
204+
{{- end -}}
205+
{{- with .Site.Home.OutputFormats.Get "rss" -}}
206+
<li><a href="{{ .RelPermalink }}">All site content</a></li>
147207
{{- end -}}
148-
{{- end -}}
149-
{{- with .Site.Home.OutputFormats.Get "rss" -}}
150-
<li><a href="{{ .RelPermalink }}">All site content</a></li>
151-
{{- end -}}
152208
</ul>
153209
</div>
154210
</section>
155-
</aside>
211+
</aside>

static/icons/book.svg

+1
Loading

static/icons/calendar.svg

+1
Loading

static/icons/group.svg

+1
Loading

0 commit comments

Comments
 (0)