-
|
Hi, sincere apologies as I am probably missing something really obvious. (I'm on Eleventy v1.0) QuestionWhere can I find the data from the Data Cascade when writing a filter ( Longer QuestionI'm building a filter (using Nunjucks, but I figured the answer wouldn't depend on that; spoilers it might), and in order to perform the filter, I need some global data. Specifically, I'm using a filter to sort by a frontmatter attribute, but I would like to sort things differently depending on the value of the attribute. To be concrete, some posts are part of a "series," but different "series" get sorted differently---some by date, some by title, some by a provided attribute. I'm storing information about each series separately so each post doesn't have to duplicate the same metadata. eleventyConfig.addNunjucksFilter("dateSeriesGroupBy", (arr) => {
// sort by a frontmatter property, but use data from the cascade
// to determine how to sort
}What I've tried so far
Thank you for any help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Not 100% sure I understand what you're asking for, but there is https://www.11ty.dev/docs/filters/#scoped-data-in-filters which recommends But let me try and build a better example in a second and get back to you with some Nunjucks and LiquidJS and .11ty.js ideas (for other languages you're on your own). |
Beta Was this translation helpful? Give feedback.
Not 100% sure I understand what you're asking for, but there is https://www.11ty.dev/docs/filters/#scoped-data-in-filters which recommends
function (arr) {...}syntax versus arrow functions(arr) => {...}so you have some additional variables inthis.scope.But let me try and build a better example in a second and get back to you with some Nunjucks and LiquidJS and .11ty.js ideas (for other languages you're on your own).