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: pass metadata to before callback #1209

Merged
merged 1 commit into from Feb 18, 2022

Conversation

vseventer
Copy link
Contributor

This PR adds a second argument for passing page data in the paginations' before callback.

This is useful (especially when leveraging the Data Cascade, where a piece of metadata might be elsewhere in the cascade) when you want to process (filter or modify) based on a value in the frontmatter:

---js
{
  keyword: "item3",
  pagination: {
    data: "items",
    size: 1,
    before: function(data, metadata) {
      return data.filter(el => el === metadata.keyword);
    }
  },
  items: ["item1", "item2", "item3", "item4", "item5", "item6"]
}
---
{{ pagination.items[0] }} <- item3

@vseventer
Copy link
Contributor Author

Hi @zachleat - what is the process for getting this looked at? If there's anything I can do, let me know!

Copy link
Contributor

@MadeByMike MadeByMike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me

@zachleat
Copy link
Member

Some commentary at #1522

@zachleat zachleat merged commit aba3a57 into 11ty:master Feb 18, 2022
@zachleat
Copy link
Member

Shipping with 1.0.1, earliest canary is 1.0.1-canary.4

@zachleat zachleat added this to the Eleventy 1.0.1 milestone Feb 18, 2022
zachleat added a commit to 11ty/11ty-website that referenced this pull request Feb 18, 2022
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.

None yet

3 participants