Once again running into an issue that may be from my rather poor reading ability
I’m trying to get a selection of pages based on a year input. “2021” for example so that I can paginate it and loop through in batches of X. However I am getting stuck on the date. Neither option below seems to work despite my understanding that the outer where
should allow me to filter based on the context of the pages of the inner where.
{{ range where (where .Site.Pages "Section" "posts") .Date.Year "2021" }}
{{range where (where .Site.Pages "Section" "posts") (.Date.Format "2006") "ge" "2021" }}
If I remove the outer where statement and range through it the context .Date.Format comes out right and I can slice by it and then range over the slice but it seems like a workaround rather than the proper way. Plus I have yet to test pagination for X pages using the slice.
{{ $archYear := .Date.Format “2006” }}
{{ $posts := slice}}
{{ $annualPosts := where .Site.Pages “Section” “posts” }}
{{range $annualPosts }}
{{if eq (.Date.Format “2006”) $archYear}}
{{ $posts = $posts | append . }}
{{end}}
{{end}}
I appreciate any help and any explanation or pointing in the right direction.