Another list page just for 2n+ pagination?

I have a blog section, where I want a featured article at the top, then the start of a paginated section with the rest of the articles. Here’s how I accomplished that:

{{ define "blog" }}
<main class="blog-index">

  {{if .Content }}
  <section class="title-area">
    {{ .Content }}
  </section>
{{ end }}
  <section class="featured">
    {{ range (where .Pages.ByDate.Reverse "Params.featured" true) }}
      {{ partial "blog/blog-item-featured.html" . }}
    {{ end }}
  </section>
  <section class="the-rest">
    {{ $notFeatured := .Paginate (where .Pages "Params.featured" false) }}
    {{ range $notFeatured.Pages }}
      {{ partial "blog/blog-item.html" . }}
 {{ end }}

  </section>
<section class="page-numbers">
{{ template "_internal/pagination.html" . }}
</section>
</main>

{{ end }}

On the next pages, (page 2, 3 etc) I do not want to show the featured item(s) – just the paginated articles. Is it possible to create a template that is just used for pagination, that or to exclude the featured section on “next pages”?

Actually just found a PageNumber attribute. Solved with:

{{ define "blog" }}
<main class="blog-index">
  {{if .Content }}
  <section class="title-area">
    {{ .Content }}
  </section>
{{ end }}
{{ $Featured:= ".Params.featured true" }}
{{ $notFeatured := .Paginate (where .Pages "Params.featured" false) }}
{{ if and $Featured (eq $.Paginator.PageNumber 1) }}
  <section class="featured">
    {{ range (where .Pages.ByDate.Reverse "Params.featured" true) }}
      {{ partial "blog/blog-item-featured.html" . }}
    {{ end }}
  </section>
{{ end }}
  <section class="the-rest">
    {{ range $notFeatured.Pages }}
      {{ partial "blog/blog-item.html" . }}
 {{ end }}
  </section>
<section class="page-numbers">
{{ template "_internal/pagination.html" . }}
</section>
</main>
{{ end }}
1 Like