@foxpro/astro-svg-components
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

Import SVG files as astro components

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

Config:

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

Astro file:

---
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 <svg> element
<CircleIcon class="icon">
{icons.map((Icon) => <Icon class="icon" />)}

tsconfig:

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

Dependencies (0)

    Dev Dependencies (9)

    Package Sidebar

    Install

    npm i @foxpro/astro-svg-components

    Weekly Downloads

    0

    Version

    0.1.3

    License

    MIT

    Unpacked Size

    6.38 kB

    Total Files

    6

    Last publish

    Collaborators

    • foxpro