Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

97
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda