I want to show only upcoming events on the homepage, and then limit to three. I'm able to loop through all the events, but I'm not able to figure out how to setup the filter.
I set this up originally but realized that the loop stops at the limit 3 I set:
{% capture now %}{{ 'now' | date: "%Y-%m-%d" }}{% endcapture %}
{% for event in site.events limit:3 %}
{% capture date %}{{ event.date | date: "%Y-%m-%d" }}{% endcapture %}
{% if date >= now %}
Therefore, I realize I need to setup the filter entirely outside the for loop, and then loop through that filtered array.
Here's what I was thinking would work instead, but it doesn't work:
{% capture now %}{{ 'now' | date: "%Y-%m-%d" }}{% endcapture %}
{% capture date %}{{ site.events | date: "%Y-%m-%d" }}{% endcapture %}
{% assign filtered_events = site.events | where_exp:"date", "date >= now" %}
{% for event in filtered_events limit:3 %}
<!--insert content-->
{% endfor %}
I know I probably need to use a where_exp which returns a filtered array that's that I can loop through but just can't figure out how to set this up. Thanks for the help!