Skip to content
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

Pagination: let data key be a function #1711

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Jaza
Copy link
Contributor

@Jaza Jaza commented Mar 26, 2021

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
Copy link
Contributor Author

Jaza commented Mar 30, 2021

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 #332 (comment) 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 Jaza force-pushed the pagination-data-key-func branch from 26be650 to 313c7fa Compare July 19, 2021 04:21
@Jaza
Copy link
Contributor Author

Jaza commented Jul 19, 2021

@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
Copy link
Contributor Author

Jaza commented Mar 14, 2022

@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?

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 Jaza force-pushed the pagination-data-key-func branch from 77b5ed5 to 37ef0f6 Compare May 11, 2022 23:50
@Jaza
Copy link
Contributor Author

Jaza commented May 11, 2022

Rebased against latest master and resolved conflicts

@m4rrc0 m4rrc0 mentioned this pull request Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants