-
-
Notifications
You must be signed in to change notification settings - Fork 493
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
Double-layered pagination? #332
Comments
I don't think there's a straightforward way. There are a couple issues about this but I don't think a solution was found, without some custom modules/preprocessing.
But there's this idea from the docs (I haven't tried this approach for anything): Basically, let Eleventy compile a file and output it to the edit: This statement, specifically:
If you give this a go and if it works, please let us know how it goes. |
Another idea might be to add a custom collection that outputs the data you want. Essentially recreate all the tag page collections, but one entry per page, rather than one per tag. |
This is a fascinating idea—I’ve been mulling it over since you posted it. I think you can do this, but you would have to flatten your custom collection to a single layer to do it. Use custom collections: https://www.11ty.io/docs/collections/#advanced%3A-custom-filtering-and-sorting. Here’s how it would work:
and then in your template it might look like this:
Does that make sense? |
This is really cool! |
Looks great! Lemme test it out as soon as I can :D |
|
The vredeburg theme uses very similar approach! You can check it out there! |
Hi, I'm using your code @zachleat to paginate my tags, but it takes all collections and I just need to paginate my collection "store" that have some tags like "Adventure", "RPG"... I already see the filter API but I don't know how to use that. Can someone help me, please? |
@TheReyzer I think the secret would be to maybe eleventyConfig.addCollection("doublePagination", function(collection) {
// Get unique list of tags
let tagSet = new Set();
- collection.getAllSorted().map(function(item) {
+ collection.getFilteredByTag("store").map(function(item) { |
I've tried but it keeps paging between categories, ideally, it would be paging between items in each category, not the categories themselves. anyway thanks, but I'm giving up on 11ty unfortunately I can't continue. |
I finally make it work right for my case. But I need make it reverse, I use
The code:
Can someone help me, please? |
@TheReyzer Does something like |
Absolutely, thank you so much! Help a lot. |
For reference: I feel like the following comment might be useful to some people landing here. Originally posted by @therealshark in #136 (comment) BlogTemplate.js
BlogTemplateEn.11ty.js
That way you don't need to duplicate code. |
I am relatively new to Eleventy, so maybe I am being naïve in the way I approach this problem but... I see 2 options:
In any case, we still make the build fail if writing to the same output twice so it is up to the us to avoid colliding premalinks. |
Does @zachleat code work for any key in the front matter, let's say "category", or is it only for "tags" key? |
Also just in case anyone is still following this, it seems that this doesn’t play well with Hacked around to make it work but kept running run into issues, like tags filtered being ignored in the output altogether, which is the other extreme. Need to go of this unsolved for the time being, but if this happens to ring a bell to anyone, any feedback appreciated! Edit: Not the most elegant solution (it would be nicer to hook this up to “filterTagList”), but it turned out to be fairly easy to do by adding something like |
I noted the above example used the collections API but here’s another way to do it in Eleventy 3.0 with the pagination |
This looks like a better way to do it, great Zach! |
I'm creating a blog. Each post are tagged. I've created each tag with the zero maintenance tag pages tip.
But each tag can potentially contain lots of posts. Can Eleventy create paginated tag pages?
EG:
And so on.
The text was updated successfully, but these errors were encountered: