Finding the newest blog post in 11ty (nunjucks)

This is one of those things I had to think through because it is really a JS question and not a template question, so the first trick is to get in the right mind set.

Then you do this:

{%- for post in collections.blog | reverse -%}
{%- if loop.index0 < 1 -%}
{{ Write all the things }}
{%- endif -%}
{%- endfor -%}

Reverse the sort order of your blog collection, or whatever you tag your blog collection with, grab the entry with an index position of zero, write out your values.

Simple. No fancy hoop jumping. No racing around trying plugins that claim to help with such things.

So simple no one bothered to write it down and I had it figure it out myself.

Okay, there is probably a better way to do that that doesn't involve walking the entire collection, and some day I will figure it out. But since it only affects build time…