Blot

First item in entries array

I'd like to create a link to the most recent post with a specific tag. I can use {{recent_entries}} or {{all_entries}} and filter by tag but I can't find a way to get (or reference) only the first result.

Elsewhere I have pagination of entries working as I want so I don't want to change local.page_size for the whole blog.

Is this possible please?

Asked 5 years ago Edit
3 replies

Answering my own question. To get the most recent item for a specific tag I can use:

{{#all_tags}} {{#entries.0}} {{#tagged.coffee}}

{{/tagged.coffee}}

{{/entries.0}} {{/all_tags}}

This is because all_tags outputs each tag with an array of entries in that tag so I can cycle through the first item (using .0) and then filter by the tag I want.

5 years ago Edit

This might be horrible - I am new to moustache but it works.

5 years ago Edit

That is an impressive answer! It works

5 years ago Edit

Your reply