I try to do the same things
In my hbs custom template, I have this code:
{{#get "posts" filter="published_at:>='2021-01-01'+published_at:<='2021-12-31'" limit="all"}}
{{posts.length}} posts in 2021
{{/get}}
{{#get "posts" filter="published_at:>='2020-01-01'+published_at:<='2020-12-31'" limit="all"}}
{{posts.length}} posts in 2020
{{/get}}
It works and I can access to my posts like that. But can I put everything in a for loop with range from this year to 20 years ago?
It seems that we can create a custom helper to do that, but if I understood correctly I need to add this helper to Ghost core js files and not just in my theme