Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions _includes/upcoming-events.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{% comment %}
This include shows upcoming events on the home page.
It only displays if there are upcoming events.
{% endcomment %}

{% assign all_events = site.posts
| where_exp: "item", "item.hidden != true"
| where_exp: "item", "item.categories contains 'events'"
| sort: "event.start_date"
%}

{% capture nowunix %}{{'now' | date: '%s'}}{% endcapture %}
{% assign has_upcoming_events = false %}

{% comment %}First pass: check if there are any upcoming events{% endcomment %}
{% for post in all_events %}
{% assign start_date = post.event.start_date | date: "%Y-%m-%d" %}
{% capture posttime %}{{ start_date | date: '%s'}}{% endcapture %}
{% if posttime > nowunix %}
{% assign has_upcoming_events = true %}
{% break %}
{% endif %}
{% endfor %}

{% comment %}Only render the section if there are upcoming events{% endcomment %}
{% if has_upcoming_events == true %}
<section class="upcoming-events-section">
<h2>Upcoming Events</h2>
<div class="entries-grid">
{% for post in all_events %}
{% assign start_date = post.event.start_date | date: "%Y-%m-%d" %}
{% capture posttime %}{{ start_date | date: '%s'}}{% endcapture %}
{% if posttime > nowunix %}
<div class="upcoming">
{% include event-cards.html %}
</div>
{% endif %}
{% endfor %}
</div>
<p class="text-center">
<a href="{{ '/events.html' | relative_url }}" class="btn btn--primary">View All Events</a>
</p>
</section>
{% endif %}
4 changes: 4 additions & 0 deletions _pages/home.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ peer-review:

<br clear="both">

{% include upcoming-events.html %}

<br clear="both">

<!-- pull blog posts not events -->
{% assign blog_posts = site.posts | where_exp: "item", "item.categories contains 'blog-post'" %}

Expand Down