#All astro Files in folder to a single Astro File.

1 messages · Page 1 of 1 (latest)

misty shard
cinder zephyr
#

and if you would rather use import declarations, you can create an index file

plush gull
misty shard
#

So you'd do something like

---
const components = await Astro.glob('Games/*.astro')
---

and components would be a list of the imported Astro components

plush gull
misty shard
#

what do you mean by Collective?

plush gull
#

by collective i mean the astro file into which all of the components are being added.

#

in image it's CollectiveGames.astro

misty shard
#

ah yeah

#

as long as you use components in that component e.g.

---
const Components = await Astro.glob('Games/*.astro')
---

<Components/>
#

or something like that

plush gull
#

ok. leme give it a try.

#

this is a single component itself. That's what's inside

sudden idol
#

You need to loop through the components array

#
---
const components = await Astro.glob('Games/*.astro')
---

{
component.map((component)=> <component.default />)
}