How to filter mainSections posts based on frontmatter dates

I have posts in various directories. I want to focus my top page on posts in my /events directory. The frontmatter of each “event” post includes eventDate.

I want to show upcoming events separately from old events. I was able to make (theme)/events/list.html show events the way I want.

I want this list of events to be my top page, so I put “events” in mainSections of my config.toml, but have not figured out how to get (theme)/list.html to both filter on mainSection AND on frontmatter.

I have a test repo here GitHub - thunderrabbit/bfr-evention: how to use frontmatter to filter pages in mainSection?

I found Group And Filter Site mainSections but cannot understand how to apply it to my situation.

How can I show only upcoming events on my top page?

The simplest approach:

{{ range where (where .Site.RegularPages "Type" "events") "Params.eventDate" "ge" now }}
1 Like