Updated Icon Utility
This commit is contained in:
@@ -22,6 +22,8 @@ npm i @wrnexus/astro
|
||||
Theme Use
|
||||
|
||||
```bash
|
||||
@import "@wrnexus/astro/theme.css";
|
||||
|
||||
@import "tailwindcss";
|
||||
|
||||
@theme {
|
||||
|
||||
+12
-4
@@ -2,11 +2,19 @@ export const getDynamicIcon = async (name: string): Promise<string> => {
|
||||
let icon = "";
|
||||
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;
|
||||
}).catch(error => {
|
||||
console.error('Failed to load icon:', error);
|
||||
});
|
||||
} catch {
|
||||
await import(`../data/iconify/${prefix}.json`).then(module => {
|
||||
icon = module.icons[iconName].body;
|
||||
}).catch(error => {
|
||||
console.error('Failed to load icon:', error);
|
||||
});
|
||||
}
|
||||
|
||||
return icon
|
||||
}
|
||||
Reference in New Issue
Block a user