Modifying collections #2045
Unanswered
cfjedimaster
asked this question in
General
Replies: 1 comment 4 replies
-
A collection is "just" a list of things. Such things can be Markdown files, with your usage of But even if you don't define this specific collection, any template file will be transformed into another file (often HTML) in the build folder. So removing items from your collection with If you don't want a source file to become a built file, its Additionally, you can indeed have any number of collections. For example:
|
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
On my site, I create a collection via glob:
I then loop over them all and tweak the permalink and outputPath. This was done to ensure my URLs didn't change when I first migrated to Eleventy.
I'm testing something (not really relevant right now) and I wanted to see what would happen if I removed items from a collection. I built my logic, and then used
posts.splice(i,1)
to remove items. I console.log the size and could confirm that the right number of items were removed, but Eleventy still wrote out each and every post.So my question is - we're allowed to modify collection data, but not remove?
On the flip side, what about adding? If we can't remove, I could perhaps use two collections. The initial collection based on glob, and a second collection where I add one by one. Is that allowed?
Beta Was this translation helpful? Give feedback.
All reactions