An open API service indexing awesome lists of open source software.

https://github.com/mrfoxpro/astro-svg-components


https://github.com/mrfoxpro/astro-svg-components

Last synced: over 1 year ago
JSON representation

Awesome Lists containing this project

README

          

Import SVG files as astro components

Install:
`pnpm i -D @foxpro/astro-svg-components`

Config:

```js
import astroSvgComnponents from '@foxpro/astro-svg-components'
export default defineConfig({
integrations: [astroSvgComnponents()],
// optional! alias
vite: {
resolve: {
alias: [
{
find: '@',
replacement: path.resolve('.'),
},
],
},
},
})
```

Astro file:

```jsx
---
import CircleIcon from '@/svgs/circle.svg?component-astro'
const icons = import.meta.glob('@/svgs/*.svg', { as: 'component-astro', eager: true })

import { globSVG } from '@foxpro/astro-svg-components'
const icons = globSVG('@/svgs/*.svg')
---
// Props are passed to element

{icons.map((Icon) => )}
```

tsconfig:

```json
{
"compilerOptions": {
"types": ["@foxpro/astro-svg-components/types"]
}
}
```