From 653d5b005bb336406eb5a670dcb4bda223d3c76e Mon Sep 17 00:00:00 2001 From: Ajay Ghanwat Date: Sat, 16 Aug 2025 12:01:55 +0530 Subject: [PATCH] Updated Icon Utility --- README.md | 2 ++ src/utils/icon.ts | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ae96d05..6365b14 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ npm i @wrnexus/astro Theme Use ```bash +@import "@wrnexus/astro/theme.css"; + @import "tailwindcss"; @theme { diff --git a/src/utils/icon.ts b/src/utils/icon.ts index 26a7d74..74dc60f 100644 --- a/src/utils/icon.ts +++ b/src/utils/icon.ts @@ -2,11 +2,19 @@ export const getDynamicIcon = async (name: string): Promise => { 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 } \ No newline at end of file