I want to create collections dynamically in 11ty.js and for that i have a block of code like so
eleventyConfig.addCollection("myGithub", (collection) => {
const result = collection.getAll()[0].data.myGithub
const tags = collection.getAll()[0].data.myGithub.tags
tags.forEach(tag => {
console.log('hello')
eleventyConfig.addCollection(`tag${tag}`, (collection) => {
const repos = collection.getAll()[0].data.myGithub.repos
console.log('hello')
return repos.filter(repo => {
return repo.data.tags.includes(tag)
})
})
});
console.log(Object.keys(collection.getAll()[0].data.collections))
return result
})
but this seems to skip the inner eleventyConfig.addCollection as i don't see those console.log statements, and i am wondering if something in 11ty is stopping me from doing this. if not, what am i doing wrong?
not always, but sometimes i also get an error like
UserConfigError: config.addCollection(HTML) already exists. Try a different name for your collection.