Hello
I would like to show the posts of a given year when a user goes for exemple to https://…/year/2021
So I added those lines in the routes.yaml
routes:
/year/2019/:
controller: channel
filter: published_at:>='2019-01-01'+published_at:<='2019-12-31'
order: published_at asc
/year/2020/:
controller: channel
filter: published_at:>='2020-01-01'+published_at:<='2020-12-31'
order: published_at asc
/year/2021/:
controller: channel
filter: published_at:>='2021-01-01'+published_at:<='2021-12-31'
order: published_at asc
It’s working well, but I want this feature for the last 30 years…
So I tried another approach:
I created a custom-year.hbs template with:
(...)
{{#post}}
{{#get "posts" filter="published_at:>='{{title}}-01-01'+published_at:<='{{title}}-12-31'" visibility="all" limit="all"}}
<li>{{posts.length}} posts this year so far ({{date format="YYYY"}})</li>
<div class="post-feed">
{{#foreach posts visibility="all"}}
{{> "post-card"}}
{{/foreach}}
</div>
{{/get}}
{{/post}}
And If I create a page named “2021” with this template, it works.
But still, I need to create 30 pages.
Is there a way to use the routes.yaml with a {slug} to do that ?