-
Hi! I'm using the following filter in my eleventy.js file:
The filter is used in the following Nunjucks template:
I have 5 posts with essentially the following frontmatter:
When I specify a size of 4 for the pagination, I get two pages with one post per page. When I specify a size of 1 for the pagination, I get the following error:
Someone suggested using pagination.items instead of posts in the for-loop, but that did not have any effect on the problem. I am not sure whether I'm just doing something wrong or if there is an actual bug. Any insights are appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Is this a dupe of #1601? |
Beta Was this translation helpful? Give feedback.
-
It's the same issue. I'm just posting it here as well. :-)
|
Beta Was this translation helpful? Give feedback.
-
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:
Frontmatter afterwards:
The Nunjucks template then goes from:
to:
I'd suggest having the docs call out that using the Javascript frontmatter is the only way to do this sort of thing. None of the templating languages seem to support adding a function as the before: property (which I guess makes sense). |
Beta Was this translation helpful? Give feedback.
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:
Frontmatter afterwards: