website
git clone https://git.pyrossh.dev/website
木 Personal website of pyrossh. Built with astrojs, shiki, vite.
b33c79e
— pyrossh
2026-07-04T14:45:48+05:30
feat: add DynamicIcon component for vscode-icons
src/components/DynamicIcon.astro
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
import allIcons from "@iconify-json/vscode-icons/icons.json" assert { type: "json" };
|
|
3
|
+
|
|
4
|
+
export interface Props {
|
|
5
|
+
name: string;
|
|
6
|
+
size?: string;
|
|
7
|
+
color?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { name, size = "24px", color = "currentColor" } = Astro.props;
|
|
11
|
+
const iconData = allIcons.icons[name as keyof typeof allIcons.icons] ?? allIcons.icons["default-file"];
|
|
12
|
+
const svgPath = iconData?.body ?? "";
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
<svg
|
|
16
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
17
|
+
width={size}
|
|
18
|
+
height={size}
|
|
19
|
+
viewBox="0 0 24 24"
|
|
20
|
+
fill="none"
|
|
21
|
+
stroke="currentColor"
|
|
22
|
+
stroke-linecap="round"
|
|
23
|
+
stroke-linejoin="round"
|
|
24
|
+
color={color}
|
|
25
|
+
set:html={svgPath}
|
|
26
|
+
/>
|