eleventy icon indicating copy to clipboard operation
eleventy copied to clipboard

Pagination: let data key be a function

Open Jaza opened this issue 3 years ago • 4 comments

So that pagination data key can be determined dynamically, based on a callback function that gets passed all template data. So you can do something like:

---js
{
  pagination: {
    data: (data) => {
      return "collections." + data.foo;
    },
...

Jaza avatar Mar 26 '21 06:03 Jaza

I just stumbled across https://www.webstoemp.com/blog/basic-custom-taxonomies-with-eleventy/ , which led me to #332 , which I see has a multitude of other issues linked to it.

In case I didn't make it clear before (I don't think I did): this PR solves double pagination! (My other recently-opened PR #1697 also solves it, but I think this one is more elegant). That's exactly why I made this change - to make pagination work on tag pages.

@zachleat your code in https://github.com/11ty/eleventy/issues/332#issuecomment-445236776 is ok as an interim solution, but I think "double pagination" should be made possible in Eleventy, without having to copy-paste so much code (and you're kind of duplicating the chunking that the pagination plugin does internally).

So, this is potentially all we need, to fulfil the enhancement item #461 , which I see has quite a few votes, and is currently pinned.

Please consider getting this in!

Jaza avatar Mar 30 '21 22:03 Jaza

@zachleat any chance you could take a look at this? Has been more than 3 months. There has been no other progress in resolving the double pagination problem, as far as I'm aware.

Jaza avatar Jul 19 '21 04:07 Jaza

@zachleat please? This PR has been up for a whole year now. I've been running this change in production for that whole time too. Would you mind reviewing it?

Jaza avatar Mar 14 '22 05:03 Jaza

Rebased against latest master and resolved conflicts

Jaza avatar May 11 '22 23:05 Jaza