Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

96
Visualizações
eleventy collections api - add collections dynamically

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.
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda