So my title may not be super clear, but what I’m trying to do is range my blog posts on a list.html
template which allows the first nth posts to be formatted differently without the formatting continuing onto page 2, 3, etc. I’m basically trying to create a “featured articles” section based on publish date (not tagging or categories).
On my list.html template
{{ range $index, $page := (.Paginate (where .Data.Pages "Type" "blog")).Pages }}
{{ if and (eq $index 0) (eq $.URL "/blog/") }}
{{ .Render "featured" }}
{{ else }}
{{ .Render "li" }}
{{ end }}
{{ end }}
{{ partial "pagination.html" . }}
This renders the first post as a “featured” template, but it will also render the first post on page 2 as a featured template as well. In addition to the above, I also tried using first
and after
but everything I’d tried extends to page 2 and so on.
I’ve been tinkering with a url filter like (eq $.URL "/blog/")
to recognize the first page only, but as of right now it still renders on page 2 and beyond.
Anyone have any suggestions here?