g1t/apps/docs/src/components/LucideIcon.astro
| 1 | --- |
| 2 | // One Lucide icon by its name on lucide.dev (kebab-case, like `git-branch`). |
| 3 | // Every interface icon in the docs comes from Lucide; see CONTRIBUTING.md. |
| 4 | import { icons } from '@lucide/astro'; |
| 5 | import type { LucideProps } from '@lucide/astro'; |
| 6 | |
| 7 | type Props = LucideProps & { name: string }; |
| 8 | |
| 9 | const { name, ...rest } = Astro.props; |
| 10 | const key = name.replace(/(^|-)([a-z0-9])/g, (_, __, c: string) => c.toUpperCase()) as keyof typeof icons; |
| 11 | const Icon = icons[key]; |
| 12 | if (!Icon) throw new Error(`No Lucide icon named "${name}". Pick one from https://lucide.dev/icons.`); |
| 13 | --- |
| 14 | |
| 15 | <Icon {...rest} /> |