{% for year, posts in section.pages | group_by(attribute="year") %}
<h2>{{ year }}</h2>
<ul>
{% for post in posts %}
<li><a href="{{ post.permalink }}">{{ post.title }}</a></li>
{% endfor %}
</ul>
{% endfor %}
to list the blog posts I’ve written and it works great.
However, now I want to filter out posts that are post-dated (having a date property in the future). This way I could do scheduled releases without having to use draft and redeploying.
I did not find anything more straightforward than this:
{% for page in section.pages %}
{% if page.date %}
{% set page_time = page.date|date(format="%s")|int %}
{% set curr_time = now()|date(format="%s")|int %}
{% if page_time < curr_time %}
Hello from the past
{% else %}
Hello from the future
{% endif %}
{% endif %}
{% endor %}