-
-
Notifications
You must be signed in to change notification settings - Fork 506
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
Add frontmatter option to reverse pagination collection #194
Comments
This repository is now using lodash style issue management for enhancements. This means enhancement issues will now be closed instead of leaving them open. The enhancement backlog can be found here: https://github.com/11ty/eleventy/issues?utf8=%E2%9C%93&q=label%3Aneeds-votes+sort%3Areactions-%2B1-desc+ Don’t forget to upvote the top comment with 👍! |
👍 for something like this. I've followed the guide on posts pagination (a vanilla blog post setup), and simply can't get it to reverse the complete posts collection before paginating it. Example: ---
title: Writings
layout: layouts/main
pagination:
data: collections.post
size: 10
---
{%- for post in posts -%}
<!-- Will sort all posts in ascending order, then paginate on 10 per page -->
{%- endfor -%}
{%- for post in posts | reverse -%}
<!-- Will paginate on 10 per page, then sort in descending order -->
{%- endfor -%} Feels like a pretty prio use case 💞 |
(Comment largely copied from #147, as requested by @zachleat. It would seem this issue has been reported a few times now!) Currently, I have the following collection defined in my config:
which I paginate like so:
This results in the following – and correct – pagination (10 being the most recent item, 1 the oldest):
Now, I’d been hoping that I could do away with defining so many collections in my config, and instead use tags. However, as there’s no means of declaratively reversing a collection before it gets paginated, items are now paginated like so:
Using Liquid’s
Basically, there needs to be a means of reversing the order of items in a collection and/or the order of paginated pages. Maybe something like:
or perhaps:
|
@zachleat Had a thought regarding this. Perhaps rather than (or in addition to) reversing a collection’s order at the pagination level, perhaps there should be an option to set a default order at the global (or folder) config level? As my site displays content from newest to oldest, pretty much every collection I’m using requires reversal before it can being used because 11ty sorts collections from oldest to newest by default. Essentially, 11ty could provide a means of using |
I'm reversing the order of pretty much everything for the same reason. |
|
Thanks @zachleat! As to document the impact of this change, I’ve now been able to remove 33 lines from my config where I was globbing files to create collections and then reversing them. I’d be able to simplify my setup further by setting the default globally – indeed, still having to hack around this limitation in places, but progress all the same. Thanks again for all you hard work on this project! |
Awesome @paulrobertlloyd! That’s a good win. |
Just spitballing here.
Raised in #192
The text was updated successfully, but these errors were encountered: