Pagination - handling later pages

Hi All,
I have this code which shows the full “content” of a post for the first post on the index page, and then shows only the “summary” for later posts on the index page:

  <div style="min-height:56vh">
      {{- range first 1 (where .Paginator.Pages "Section" "post") }}
        {{ .Render "full_content" }}
      {{- end }}
  </div>
  <br />
  <div style="min-height:56vh">
      {{- range after 1 (first 5 (where .Paginator.Pages "Section" "post")) }}
        {{ .Render "summary" }}
      {{- end }}
  </div>

It works well on the main / front index page (aka the hompage), but it also shows the full “Content” at the top of the second page (and at the top of later pagination pages), as well. I really only want it to show the full “content” of a post if the post is the first post on the page and that post is on the home page. For later pages, I want it to only show the “summary” of each post.

Might someone assist?

I think they solve your issue at IsHome returning true on /page/2. :slight_smile:

1 Like

Thanks - I went with:

      {{ if lt .Paginator.PageNumber 2 }}
      <div style="min-height:56vh">
          {{- range first 1 (where .Paginator.Pages "Section" "post") }}
            {{ .Render "full_content" }}
          {{- end }}
      </div>
      <br />
      <div style="min-height:56vh">
          {{- range after 1 (first 10 (where .Paginator.Pages "Section" "post")) }}
            {{ .Render "summary" }}
          {{- end }}
      </div>
      {{ else }}
      <div style="min-height:56vh">
          {{- range where .Paginator.Pages "Section" "post" }}
            {{ .Render "summary" }}
          {{- end }}
      </div>
      {{ end }}

And this seems to work! I appreciate your help!

Jim

1 Like