Allow computed data to configure special Eleventy Data properties (like pagination) (👍12) #4029
Replies: 13 comments
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
-
|
^_^ Computed properties are actually coming to Eleventy: https://www.11ty.dev/docs/data-computed/. The feature is on master so I was trying it out early. |
Beta Was this translation helpful? Give feedback.
-
|
This docs page is extremely relevant to this discussion: https://www.11ty.dev/docs/advanced-order/ Hmm, let me ponder this one. |
Beta Was this translation helpful? Give feedback.
-
|
We could move this up in the order of operations but that would have a lot more undesirable implications, specifically I think it would create a circular dependency on computed permalinks (and you wouldn’t be able to access Hmm. At the very least we should throw an error when computed data overrides something used as a pagination key. |
Beta Was this translation helpful? Give feedback.
-
|
Alright, after some consideration I do think this would be a worthwhile feature but will be a Version 2 iteration of the feature. Note that the docs do currently say “At the end of the Data Cascade.” I’m going to modify this issue and put it into the enhancement queue. There are a bunch of special data props in Eleventy that we could use this feature to transform and each of them will require a special case in the order of operations. e.g.:collections |
Beta Was this translation helpful? Give feedback.
-
|
In the mean time use the |
Beta Was this translation helpful? Give feedback.
This comment has been hidden.
This comment has been hidden.
-
|
Hadn't thought of the
All in all, I think I'm not going the right way about those supported locales, so I'll have a rethink about how I use things. Thanks again for the pointers though. Regarding computing Eleventy special data props, I agree that could be super handy to give more flexibility. |
Beta Was this translation helpful? Give feedback.
-
|
I would really appreciate this feature — it would mean I could set |
Beta Was this translation helpful? Give feedback.
This comment has been hidden.
This comment has been hidden.
-
|
#4141 was a request specific to #1225 was a request for |
Beta Was this translation helpful? Give feedback.
-
|
Cross link to #3882 for |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
I'm trying to paginate some data that's returned by an
eleventyComputedproperty. Eleventy breaks announcing it cannot find the property used for the pagination:To Reproduce
The
computed-properties-paginationbranch of this repository contains a reduced test case. Thetest.liquidtemplate tries to paginate over thesupportedLocaleskey defined indata/eleventyComputed. Runnpx @11ty/eleventyto get the exception.If there's a non-computed property with the same name, it will get used for the pagination. You can witness the behaviour using the previous commit on the branch. It contains a property with the same key defined in
data/supportedLocales. Thetest.liquidtemplate does paginate, but does it over the "static" properties not the computed ones.Expected behavior
I'd have expected the computed property to be used for pagination in both cases, overriding the static ones when they are defined.
Environment:
11ty/eleventy#9109e76in package.json.Additional context
Add any other context about the problem here.
Beta Was this translation helpful? Give feedback.
All reactions