perladvent / perldotcom

The source code for Perl.com website
https://www.perl.com
77 stars 79 forks source link

Include only articles in the paginator #265

Open briandfoy opened 3 years ago

briandfoy commented 3 years ago

In the _defaults/list.html template, we have a paginator like this (once my jQuery stuff lands):

    {{ range $index, $page := .Paginator.Pages }}
      {{ if not (isset $page.Params "exclude_paginate") }}
        {{ .Render "li" }}
      {{ end }}
    {{ end }}
    {{ partial "pagination.html" .Paginator }}

Previously this excluded about.md by name because it was the only special page.

Instead of iterating over all pages then looking at their params, l'd like to make the paginator from only those that we should include. I've introduced an "exclude_pagination" param, but that is probably stupid. It's good for now.

I think we really want something like this, which is not correct syntactically. We select all the pages to include, then paginate that list.

  {{ range $index, $page := .Paginate( (where .Params "Type" "is" "article").Pages) }}