Simplify retrieval of collections.all in getLocaleCollectionItem
#3785
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change motivated by: noelforte/eleventy-plugin-vento#221
I couldn't figure out why the i18n plugin's presence was breaking the
getNextCollectionItem
andgetPreviousCollectionItem
filters since the Vento template engine plugin doesn't do anything fancy with the filters.After a lot of trial and error, I discovered that this search for collections.all at the very end of the
GetLocaleCollectionItem
module checks a lot of things specific to Eleventy's own internal engines but of course custom engines don't add actx
orcontext
object, or eventhis.collections
, sincethis.page
andthis.eleventy
are the only context keys Eleventy supports, andcollections
is already accessible in page data anyway.Rather than add
this.collections
to the Vento custom engine, could we simplify theall
declaration to search thedata
key instead since thedata
key is already available on the render context anyway?If not, I can look into adding
this.collections
to the custom engine for my plugin, but if this can be handled upstream that puts less pressure on custom engines to support adding it.Thanks Zach!