Skip to content

Pagination on filtered collection? #1603

Answered by cmcknight
cmcknight asked this question in Q&A
Discussion options

You must be logged in to vote

Problem solved. The solution is create the frontmatter as a Javascript object and use the before: property to filter the content. From that point, pagination works as expected.

Frontmatter before:

---
title: Blog
permalink: "/authors/john-doe/{% if pagination.pageNumber > 0 %}{{ pagination.pageNumber | plus: 1 }}{% endif %}/index.html"
layout: author-posts.njk
author: John Doe
pagination:
  data: collections.posts
  size: 4
  reverse: true
  alias: posts
breadcrumbs:
  - label: Home
    url: /
  - label: Blog
    url: /blog/
  - label: John Doe
---

Frontmatter afterwards:

---js
{
  title: "Blog",
  permalink: "/authors/john-doe/{% if pagination.pageNumber > 0 %}{{ pagination.pageNumber |…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Ryuno-Ki
Comment options

Answer selected by cmcknight
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants