#Cannot import svg

7 messages · Page 1 of 1 (latest)

upbeat maple
#

I'm trying the new Astro v5.0.0 beta 9 with blog starter. I try to add a svg image in a mdx file. Some icon svg files work well, but more complex svg files don't, like this.

code:

import Dragon from './dragon.svg';
...
<Dragon />

error:
TypeError: Cannot read properties of undefined (reading 'map')
Stack Trace attached as file.

hybrid steeple
#

Looks like it's an issue with ultrahtml have you tried disabling that package?

upbeat maple
hybrid steeple
#

Have you tried using Astro Icon for your SVGs? It's generally the recommended way and works great (currently using it on the v5 beta without issue)

https://www.astroicon.dev/

Astro Icon

Astro Icon simplifies working with icons in Astro

upbeat maple
hybrid steeple
#

Can use it for whatever SVG you want, but if you want to specify between them you could use the <Image /> component for the "images"

upbeat maple