I’m trying to loop over all the blog articles on our site but I want to ignore the FIRST item that has a front matter field “featured” set. We display a featured article at the top of the page but sometimes the content team leave this field in place in past featured articles so I still want to display them in our list.
{{ $done := false }}
{{ range $paginator.Pages }}
{{ if ne $done }}
// we did not ignore anything yet
{{ with .Data.Pages.Params.featured }}
{{ $done = true }}
// first time we encounter featured so set to true and don't print
{{ else }}
// no featured, so print
{{ partial "blog/list" . }}
{{ end }}
{{ else }}
// $done is set, so print
{{ partial "blog/list" . }}
{{ end}}
{{ end }}
I am pretty sure there will be also be ways to collect the pages (your first line) so that the first item with featured is filtered out. The with .Data.Pages.Params.featured comes from your sample code. Not sure if that is the proper frontmatter check. I would assume it to be .Params.featured, but maybe something is missing in your code.