#Importing multiple images and calling on component

13 messages · Page 1 of 1 (latest)

opal belfry
#

This is using Astro 4.0

I would like to create a component called Path.astro where I have all the images from assets/path/images.webp inside, and when I call the component on another, I just type something like <Path nihility/> in example, and this automatically enables the Nihility image.

Does anyone have an idea to optimally do this?

I can think of ways, but I feel like they're very suboptimal, and would still require a lot of manual work.

stoic trench
#

i wonder if there is a way to make an integration for this

#

perhaps it can tie into the astro sync event?

#

I will look into this :)

#

i assume you mean to have it typesafe

pastel kiln
opal belfry
#

I did it this way, probably not the most optimal, but it does recognize the image

#

but idk yet if I will be able to make an app around it where users can select their image to generate a card, but that's a problem for future me

stoic trench
#

I think that dynamic image import works for the way you have implemented it

#

but maybe not