Updated Icon Utility
This commit is contained in:
@@ -22,6 +22,8 @@ npm i @wrnexus/astro
|
|||||||
Theme Use
|
Theme Use
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
@import "@wrnexus/astro/theme.css";
|
||||||
|
|
||||||
@import "tailwindcss";
|
@import "tailwindcss";
|
||||||
|
|
||||||
@theme {
|
@theme {
|
||||||
|
|||||||
+12
-4
@@ -2,11 +2,19 @@ export const getDynamicIcon = async (name: string): Promise<string> => {
|
|||||||
let icon = "";
|
let icon = "";
|
||||||
let [prefix, iconName] = name.split(":");
|
let [prefix, iconName] = name.split(":");
|
||||||
|
|
||||||
await import(`../data/iconify/${prefix}.json`).then(module => {
|
const url = new URL(`../data/iconify/${prefix}.json`, import.meta.url);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// @vite-ignore prevents pre-analysis of the dynamic path
|
||||||
|
const module: any = await import(/* @vite-ignore */ url.href);
|
||||||
icon = module.icons[iconName].body;
|
icon = module.icons[iconName].body;
|
||||||
}).catch(error => {
|
} catch {
|
||||||
console.error('Failed to load icon:', error);
|
await import(`../data/iconify/${prefix}.json`).then(module => {
|
||||||
});
|
icon = module.icons[iconName].body;
|
||||||
|
}).catch(error => {
|
||||||
|
console.error('Failed to load icon:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return icon
|
return icon
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user