Pagination: using pager URLs with a 'complex' pagination logic

With reference to this topic. My pagination logic is like this in the list template (which renders the homepage and list pages).

Summary
{{/* Set Pages */}}
   {{- $pages := .Pages }}
   {{- if .IsHome }}
     {{- $p := slice }}
     {{- range (where site.Pages "Type" "post").ByDate }}
       {{- if or
         (and .IsPage (not (eq .Layout "multipage" )))
         (and .IsSection (eq .Layout "multipage" ))
       -}}
         {{- $p = $p | append . }}
       {{- end }}
     {{- end }}
     {{- $pages = $p.ByDate.Reverse }}
   {{- end }}
   {{/* Set constants. */}}
   {{- $numFeaturedPages := 2 }}
   {{- $numPagesFirstPager := 14 }}
   {{- $numPagesSubsequentPagers := 12 }}
   {{- $paginator := .Paginate ($pages | after (sub $numPagesFirstPager $numPagesSubsequentPagers)) $numPagesSubsequentPagers -}}

The rest of the layout is defined in this solution.

So, in the head template, I have to this

Summary
{{- $numFeaturedPages := 2 }}
    {{- $numPagesFirstPager := 14 }}
    {{- $numPagesSubsequentPagers := 12 }}
    {{- $paginator := "" -}}
    {{- $pages := .Pages }}
    {{- if and (.IsSection) (ne .Layout "multipage") -}}
      {{- $paginator = .Paginate ($pages| after (sub $numPagesFirstPager $numPagesSubsequentPagers)) $numPagesSubsequentPagers }}
    {{- end }}
    {{- if .IsHome }}
      {{- $p := slice }}
      {{- range (where site.Pages "Type" "post").ByDate }}
        {{- if or
        (and .IsPage (not (eq .Layout "multipage" )))
        (and .IsSection (eq .Layout "multipage" ))
        -}}
          {{- $p = $p | append . }}
        {{- end }}
      {{- end }}
      {{- $pages = $p.ByDate.Reverse }}
      {{- $paginator = .Paginate ($pages | after (sub $numPagesFirstPager $numPagesSubsequentPagers)) $numPagesSubsequentPagers -}}
    {{- end }}

So, how to use the ‘new’ implementation with this logic? cc @jmooring

For your existing site I would not change anything. Or to respectfully put it another way, this isn’t anything that I’m going to spend any time on.

If you wish to use the approach that I outlined in the tips & tricks topic you’ll need to move your pagination logic to a pagination block.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.