Skip to content

Commit

Permalink
Fixed icon system
Browse files Browse the repository at this point in the history
  • Loading branch information
LynithDev committed Jan 20, 2024
1 parent 8be3434 commit 0225e2e
Show file tree
Hide file tree
Showing 4 changed files with 368 additions and 49 deletions.
1 change: 1 addition & 0 deletions apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"test": "vitest"
},
"dependencies": {
"@astrojs/check": "^0.4.1",
"@astrojs/mdx": "^2.0.3",
"@astrojs/rss": "^4.0.1",
"@astrojs/sitemap": "^3.0.4",
Expand Down
6 changes: 4 additions & 2 deletions apps/website/src/components/icons/Icon.astro
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
import { readFile } from 'node:fs/promises';
import type { HTMLAttributes } from 'astro/types';
import { parse } from 'node-html-parser';
Expand Down Expand Up @@ -41,12 +42,13 @@ interface Props extends HTMLAttributes<'svg'> {
}
async function getSVG(name: string, path = 'impl') {
const file = await import(`./${path}/${name}.svg?raw`);
const dir = new URL(`${path}`, import.meta.url).pathname;
const file = await readFile(`${dir}/${name}.svg`, { encoding: 'utf-8' });
if (!file)
throw new Error(`${name} not found`);
const content = parse(file.default);
const content = parse(file);
const svg = content.querySelector('svg');
Expand Down
7 changes: 5 additions & 2 deletions apps/website/src/components/logos/Logo.astro
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
import { readFile } from 'node:fs/promises';
import { join } from 'node:path';
import type { LogoType } from '@webtypes/Config';
import type { HTMLAttributes } from 'astro/types';
Expand All @@ -18,8 +20,9 @@ let svg: string | undefined;
try {
if (logo === undefined)
return;
const dir = '../../../public/media';
svg = (await import(/* @vite-ignore */ `${dir}/${logo.replaceAll('.', '/')}.svg?raw`)).default;
const dir = new URL(join('..', '..', '..', 'public', 'media'), import.meta.url).pathname;
svg = (await readFile(`${dir}/${logo.replaceAll('.', '/')}.svg`, { encoding: 'utf8' }));
if (svg === undefined)
return;
Expand Down
Loading

0 comments on commit 0225e2e

Please sign in to comment.