#Received unsupported format `undefined` from `undefined`

15 messages · Page 1 of 1 (latest)

round anchor
#

Can I import an image directly into a component without having to declare the import beforehand? I am using the experimental astro assets.
<Image src={import('../assets/sport/sport-1.png')} format="webp" alt="sport" />

languid cave
#

You need to await the import

#

Dynamic imports like that are async, so right now you're passing a Promise

round anchor
languid cave
#

Why not?

#

You can do src={await import(...)}

round anchor
languid cave
#

Is this the error you get?

#

Astro components should always be able to do this

round anchor
#

Error: Transform failed with 1 error:

#

ERROR: "await" can only be used inside an "async" function

#

import works if you use <@&1055234544183287879>/image/components instead of astro:assets

#

I just want to declare the path to the images in the array and then use map to display the data in the layout