Skip to content

Commit 84ce5cf

Browse files
Add upcoming events section to home page (#791)
- Created new upcoming-events.html include file that: - Filters events by date to show only upcoming events - Only renders section if upcoming events exist - Uses existing entries-grid styling for responsive layout - Includes link to full events page - Added upcoming events section to home page after new contributors - Addresses #671 Co-authored-by: Leah Wasser <[email protected]>
1 parent 0f6627f commit 84ce5cf

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

_includes/upcoming-events.html

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{% comment %}
2+
This include shows upcoming events on the home page.
3+
It only displays if there are upcoming events.
4+
{% endcomment %}
5+
6+
{% assign all_events = site.posts
7+
| where_exp: "item", "item.hidden != true"
8+
| where_exp: "item", "item.categories contains 'events'"
9+
| sort: "event.start_date"
10+
%}
11+
12+
{% capture nowunix %}{{'now' | date: '%s'}}{% endcapture %}
13+
{% assign has_upcoming_events = false %}
14+
15+
{% comment %}First pass: check if there are any upcoming events{% endcomment %}
16+
{% for post in all_events %}
17+
{% assign start_date = post.event.start_date | date: "%Y-%m-%d" %}
18+
{% capture posttime %}{{ start_date | date: '%s'}}{% endcapture %}
19+
{% if posttime > nowunix %}
20+
{% assign has_upcoming_events = true %}
21+
{% break %}
22+
{% endif %}
23+
{% endfor %}
24+
25+
{% comment %}Only render the section if there are upcoming events{% endcomment %}
26+
{% if has_upcoming_events == true %}
27+
<section class="upcoming-events-section">
28+
<h2>Upcoming Events</h2>
29+
<div class="entries-grid">
30+
{% for post in all_events %}
31+
{% assign start_date = post.event.start_date | date: "%Y-%m-%d" %}
32+
{% capture posttime %}{{ start_date | date: '%s'}}{% endcapture %}
33+
{% if posttime > nowunix %}
34+
<div class="upcoming">
35+
{% include event-cards.html %}
36+
</div>
37+
{% endif %}
38+
{% endfor %}
39+
</div>
40+
<p class="text-center">
41+
<a href="{{ '/events.html' | relative_url }}" class="btn btn--primary">View All Events</a>
42+
</p>
43+
</section>
44+
{% endif %}

_pages/home.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ peer-review:
100100

101101
<br clear="both">
102102

103+
{% include upcoming-events.html %}
104+
105+
<br clear="both">
106+
103107
<!-- pull blog posts not events -->
104108
{% assign blog_posts = site.posts | where_exp: "item", "item.categories contains 'blog-post'" %}
105109

0 commit comments

Comments
 (0)