You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
513 B
Plaintext
22 lines
513 B
Plaintext
---
|
|
import { Image } from 'astro:assets'
|
|
|
|
type Props = {
|
|
name: string
|
|
}
|
|
|
|
const { name } = Astro.props
|
|
|
|
const icons = Object.fromEntries(
|
|
Object.entries(
|
|
import.meta.glob<{ default: ImageMetadata }>(`node_modules/@phosphor-icons/core/assets/light/*.svg`),
|
|
).map(([path, module]) => [path.split('/').pop()!.split('.')[0].replace('-light', ''), module]),
|
|
)
|
|
|
|
if (!icons[name]) {
|
|
throw new Error(`Icon "${name}" not found`)
|
|
}
|
|
---
|
|
|
|
<Image class="phosphor-icon" src={icons[name]()} alt={name} />
|