aboutsummaryrefslogtreecommitdiff
path: root/apps/website/src/components/icons/Icon.astro
diff options
context:
space:
mode:
authorLynithDev <61880709+LynithDev@users.noreply.github.com>2024-01-20 17:26:36 +0100
committerLynithDev <61880709+LynithDev@users.noreply.github.com>2024-01-20 17:26:36 +0100
commit55548a94b61ce7d1ca0ca8da69db7566f937cfeb (patch)
tree54172a78823cf76761ab88e21d6d2c64d5b965c3 /apps/website/src/components/icons/Icon.astro
parent0225e2e17d12a32467bc12f33b2402287c79e23f (diff)
downloadNexus-55548a94b61ce7d1ca0ca8da69db7566f937cfeb.tar.gz
Nexus-55548a94b61ce7d1ca0ca8da69db7566f937cfeb.tar.bz2
Nexus-55548a94b61ce7d1ca0ca8da69db7566f937cfeb.zip
FIX THE ICON SYSTEM
Diffstat (limited to 'apps/website/src/components/icons/Icon.astro')
-rw-r--r--apps/website/src/components/icons/Icon.astro12
1 files changed, 5 insertions, 7 deletions
diff --git a/apps/website/src/components/icons/Icon.astro b/apps/website/src/components/icons/Icon.astro
index f57ee4f..cfb14ca 100644
--- a/apps/website/src/components/icons/Icon.astro
+++ b/apps/website/src/components/icons/Icon.astro
@@ -1,5 +1,4 @@
---
-import { readFile } from 'node:fs/promises';
import type { HTMLAttributes } from 'astro/types';
import { parse } from 'node-html-parser';
@@ -41,9 +40,8 @@ interface Props extends HTMLAttributes<'svg'> {
size?: number | [number, number]
}
-async function getSVG(name: string, path = 'impl') {
- const dir = new URL(`${path}`, import.meta.url).pathname;
- const file = await readFile(`${dir}/${name}.svg`, { encoding: 'utf-8' });
+async function getSVG(name: string) {
+ const file = (await import(`./impl/${name}.svg?raw`)).default;
if (!file)
throw new Error(`${name} not found`);
@@ -66,7 +64,6 @@ async function getSVG(name: string, path = 'impl') {
const {
icon,
size,
- path = 'impl',
...attributes
} = Astro.props as Props;
@@ -91,7 +88,7 @@ try {
};
};
- const { attributes: baseAttributes, innerHTML } = await getSVG(icon, path);
+ const { attributes: baseAttributes, innerHTML } = await getSVG(icon);
svgAttributes = {
...baseAttributes,
...attributes,
@@ -101,7 +98,8 @@ try {
const colorRegex = /(fill|stroke)=\"([^"]*)\"/g;
html = innerHTML.replaceAll(colorRegex, '$1="currentColor"');
}
-catch (err) {
+ catch (err) {
+ console.error(err);
// ignored
}
---