Skip to content

Commit adfc29d

Browse files
committed
front: shortcode that actually uses event logos
Signed-off-by: pierre santamaria <[email protected]>
1 parent 384ddbc commit adfc29d

File tree

4 files changed

+56
-2
lines changed

4 files changed

+56
-2
lines changed

content/_index.en.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
+++
55

66
{{< blocks/cover title="" image_anchor="top" height="full" color="black">}}
7-
<img class="main-logo" src="/images/logo/logo-osrd-color-white.svg">
7+
{{< event-logo >}}
88
<h2 class="mb-5 font-weight-normal main-title">Open Source Railway Designer</h2>
99
<div class="mx-auto mt-3">
1010
<a class="btn btn-lg btn-primary mx-2 mb-4" href="{{< relref "/about">}}">

content/_index.fr.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
+++
55

66
{{< blocks/cover title="" image_anchor="top" height="full" color="black">}}
7-
<img class="main-logo" src="/images/logo/logo-osrd-color-white.svg">
7+
{{< event-logo >}}
88
<h2 class="mb-5 font-weight-normal main-title">Open Source Railway Designer</h2>
99
<div class="mx-auto mt-3">
1010
<a class="btn btn-lg btn-primary mx-2 mb-4" href="{{< relref "/about">}}">

data/events.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
- name: "Xmas"
2+
start_month: 12
3+
start_day: 1
4+
end_month: 1
5+
end_day: 1
6+
logo: "/images/logo/events/xmas-logo-osrd-color-white.svg"
7+
crosses_year: true
8+
9+
- name: "Pride"
10+
start_month: 6
11+
start_day: 1
12+
end_month: 6
13+
end_day: 30
14+
logo: "/images/logo/events/proud-logo-osrd-color-white.svg"
15+
crosses_year: false

layouts/shortcodes/event-logo.html

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{{ $currentMonth := now.Month }}
2+
{{ $currentDay := now.Day }}
3+
{{ $events := site.Data.events }}
4+
{{ $logoPath := "/images/logo/logo-osrd-color-white.svg" }}
5+
{{ $logoAlt := "OSRD Logo" }}
6+
7+
{{ range $events }}
8+
{{ $isInPeriod := false }}
9+
10+
{{ if .crosses_year }}
11+
{{/* Case in which the event period crosses the end of the year and we need to check more than just months */}}
12+
{{ if or (and (eq $currentMonth .start_month) (ge $currentDay .start_day)) (and (eq $currentMonth .end_month) (le $currentDay .end_day)) (gt $currentMonth .start_month) (lt $currentMonth .end_month) }}
13+
{{ $isInPeriod = true }}
14+
{{ end }}
15+
{{ else }}
16+
{{/* Normal case */}}
17+
{{ if and (ge $currentMonth .start_month) (le $currentMonth .end_month) }}
18+
{{ if eq $currentMonth .start_month }}
19+
{{ if ge $currentDay .start_day }}
20+
{{ $isInPeriod = true }}
21+
{{ end }}
22+
{{ else if eq $currentMonth .end_month }}
23+
{{ if le $currentDay .end_day }}
24+
{{ $isInPeriod = true }}
25+
{{ end }}
26+
{{ else }}
27+
{{ $isInPeriod = true }}
28+
{{ end }}
29+
{{ end }}
30+
{{ end }}
31+
32+
{{ if $isInPeriod }}
33+
{{ $logoPath = .logo }}
34+
{{ $logoAlt = printf "%s %s" .name $logoAlt }}
35+
{{ break }}
36+
{{ end }}
37+
{{ end }}
38+
39+
<img class="main-logo" src="{{ $logoPath }}" alt="{{ $logoAlt }}" />

0 commit comments

Comments
 (0)