Skip to content

Commit 87d863d

Browse files
Merge pull request #1021 from InnerSourceCommons/fix-call-algo
Ensure the Nearest Upcoming Event Is Displayed First
2 parents 826fec5 + af81f7d commit 87d863d

File tree

3 files changed

+34
-28
lines changed

3 files changed

+34
-28
lines changed

data/featured_articles.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,9 @@ learning:
2525
visible: true
2626

2727
community:
28-
- title: "InnerSource Gathering Berlin 2025 is open for registration!"
29-
image: "/images/photos/berlin-2025.png"
30-
link: https://gatherings.innersourcecommons.org/berlin-2025/
31-
visible: true
32-
- title: Call for Hosts for InnerSource Summit 2025
33-
image: "/images/photos/call-for-hosts.png"
34-
link: https://docs.google.com/forms/d/e/1FAIpQLSdjeQFYDVT_0pVwMJTHTmArMPLtq7oHwBO8CgQzd_aV0UxRKA/viewform
28+
- title: "InnerSource Gathering London 2025 is open for registration!"
29+
image: "https://gatherings.innersourcecommons.org/images/gathering/london-2025.png"
30+
link: https://gatherings.innersourcecommons.org/london-2025/
3531
visible: true
3632

3733
blog:

layouts/partials/header.html

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -122,19 +122,21 @@ <h4>{{ .title }}</h4>
122122
</ul>
123123
<div class="featured-articles">
124124
{{ $pages := where site.Pages "Type" "in" "redirects" }}
125-
{{ $pages = where $pages "Section" "events" }}
126-
{{ range first 1 ($pages.ByDate.Reverse) }}
127-
<div class="article-card">
128-
<a href="{{ .Params.redirect }}" class="article-link" target="_blank">
129-
<div class="article-image">
130-
<img src="{{ .Params.image }}" alt="{{ .Title }}">
131-
</div>
132-
<div class="article-content">
133-
<h4>{{ .Title }} will be held on {{ .Date.Format "January 2, 2006" }}</h4>
134-
</div>
135-
</a>
136-
</div>
137-
{{ end }}
125+
{{ $pages = where $pages "Section" "events" }}
126+
{{ $now := now }}
127+
{{ $futureEvents := where $pages "Date" "ge" $now }}
128+
{{ range first 1 ($futureEvents.ByDate) }}
129+
<div class="article-card">
130+
<a href="{{ .Params.redirect }}" class="article-link" target="_blank">
131+
<div class="article-image">
132+
<img src="{{ .Params.image }}" alt="{{ .Title }}">
133+
</div>
134+
<div class="article-content">
135+
<h4>{{ .Title }} will be held on {{ .Date.Format "January 2, 2006" }}</h4>
136+
</div>
137+
</a>
138+
</div>
139+
{{ end }}
138140
{{ range where site.Data.featured_articles.community "visible" true }}
139141
<div class="article-card">
140142
<a href="{{ .link }}" class="article-link">

layouts/shortcodes/upcoming-event-card.html

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,19 @@
22

33
{{ $pages := where site.Pages "Type" "in" "redirects" }}
44
{{ $pages = where $pages "Section" "events" }}
5-
{{ range first 1 ($pages.ByDate.Reverse) }}
6-
<div style="position: relative; border: none; box-shadow: none;">
7-
<div style="position: absolute; top: 10px; left: 10px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; color: white; background: rgba(0, 0, 0, 0.5); padding: 4px 8px; border-radius: 2px; z-index: 1;">Upcoming Event</div>
8-
<a href="{{ .Params.redirect }}" class="event-link" target="_blank" style="text-decoration: none; color: inherit; display: block; border: none;">
9-
<img src="{{ .Params.image }}" alt="{{ .Title }}" style="width: 100%; display: block; border: none; margin: 0; border-radius: 6px;">
10-
</a>
11-
</div>
12-
{{ end }}
5+
{{ $now := now }}
6+
{{ $futureEvents := where $pages "Date" "ge" $now }}
7+
{{ $upcomingEvent := first 1 ($futureEvents.ByDate) }}
8+
9+
{{ if $upcomingEvent }}
10+
{{ range $upcomingEvent }}
11+
<div style="position: relative; border: none; box-shadow: none;">
12+
<div style="position: absolute; top: 10px; left: 10px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; color: white; background: rgba(0, 0, 0, 0.5); padding: 4px 8px; border-radius: 2px; z-index: 1;">Upcoming Event</div>
13+
<a href="{{ .Params.redirect }}" class="event-link" target="_blank" style="text-decoration: none; color: inherit; display: block; border: none;">
14+
<img src="{{ .Params.image }}" alt="{{ .Title }}" style="width: 100%; display: block; border: none; margin: 0; border-radius: 6px;">
15+
</a>
16+
</div>
17+
{{ end }}
18+
{{ else }}
19+
<!-- If no upcoming events, show a placeholder or nothing -->
20+
{{ end }}

0 commit comments

Comments
 (0)