New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow empty pagination data to still generate an empty results page #731
Comments
Which template language? (Nunjucks supports an else clause for |
Nunjucks indeed. Guess I ll take a look at that. |
Did some testing and the nunjuck else clause works as advertised however the underlying problem still continues. If pagination receives an empty array, the template will not be parsed at all. Looking at the Debug output the template is found: Eleventy then (correctly) recognizes that my collection is empty: And subsequently the specific template doesn't appear in the list of templates being written into html files (example): |
Would be nice to have an additional YAML parm for a default action to take on empty collections if you want the page rendered anyway. pagination: true - Render template regardless What gets rendered in the content portion of the template would be controlled by the template if the render flag above is true. In a template, Nunjucks in this case, one could simply test for an empty collection and insert a custom message, etc.
|
Shipped #1698 and #2208 for this. Will be included with 2.0.0-canary.10 Docs will show up on https://www.11ty.dev/docs/pagination/ shortly |
Describe the bug
If pagination is handed an empty collection, the template is ignored.
To Reproduce
Steps to reproduce the behaviour:
Expected behaviour
If the collection is empty, a site with one page and no entries should be generated (being able to add a custom "no items found" message would be the icing on the cake).
Environment:
The text was updated successfully, but these errors were encountered: