On my blog I list the first 6 items in my archive listing, with the first one slightly differently formatted to kind of feature it. The problem is my pagination logic is flawed somewhere, because when I go to subsequent list pages using the arrows/numbers in the pagination footer, it skips listing the post inbetween the last on the previous page and the first on the current page.
Another way to put this is that I want to style the first item on the first blog page differently, since it’s the latest one without having to set any special front matter.
Hope that makes sense. I think I’m misunderstanding how paginator ranges work perhaps?
Here’s the code from the blog template. In my config, paginate is set to 7.
The first one selects from a different collection than the other one. Also, the sorting should not be needed, as pubDate desc is near the top in the default sort.
Thanks. My thinking behind this was because I only want the first post of the first paginated page to be different, not subsequent pages. Have I completely got this confused?
So if I do this, I get nearly the desired behaviour, but a repeat of the first post listed. How can I skip the first post in this list without doing it for subsequent paginations?
{{ $firstpage := eq .Paginator.PageNumber 1}}
{{ range $i, $e := .Paginator.Pages }}
{{ if and $firstpage (eq 0 $i) }} <!-- Page 1 AND first .Page -->
first
{{ else }}
not first
{{ end }}
{{ end }}
Thanks. I’m struggling with this a bit as it’s starting to move beyond my Go syntax skills. That stray bracket the second line after Pages – is that whole $e… part meant to be in brackets or was that end one just a typo?