Skip to content

Commit 6302a9e

Browse files
committed
refactor: hacky workaround
1 parent 5a22e92 commit 6302a9e

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

apps/website/src/root.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ export default component$(() => {
6363
<meta charSet="utf-8" />
6464
<link rel="manifest" href="/manifest.json" />
6565
<RouterHead />
66+
<script
67+
type="module"
68+
dangerouslySetInnerHTML={
69+
/*javascript*/ `
70+
import * as shikiji from 'https://esm.sh/[email protected]'
71+
window.shikiji = shikiji;
72+
`
73+
}
74+
/>
6675
</head>
6776
<body
6877
lang="en"

apps/website/src/routes/docs/_components/highlight/highlight.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ import {
33
QwikIntrinsicElements,
44
component$,
55
useSignal,
6-
useTask$,
6+
useVisibleTask$,
77
} from '@builder.io/qwik';
88
import { OmitSignalClass } from '@qwik-ui/utils';
99
import { CodeCopy } from '../code-copy/code-copy';
10-
import { getOrCreateHighlighter } from './get-or-create-highlighter';
1110

1211
export type HighlightProps = OmitSignalClass<QwikIntrinsicElements['pre']> & {
1312
code: string;
@@ -28,8 +27,7 @@ export const Highlight = component$(
2827
}: HighlightProps) => {
2928
const codeSig = useSignal('');
3029

31-
useTask$(async function createHighlightedCode() {
32-
const highlighter = await getOrCreateHighlighter();
30+
useVisibleTask$(async function createHighlightedCode() {
3331
let modifiedCode: string = code;
3432

3533
let partsOfCode = modifiedCode.split(splitCommentStart);
@@ -42,8 +40,14 @@ export const Highlight = component$(
4240
modifiedCode = partsOfCode[0];
4341
}
4442

45-
console.log(highlighter);
46-
codeSig.value = highlighter.codeToHtml(modifiedCode, { lang: language });
43+
const str = await (window as any).shikiji.codeToHtml(modifiedCode, {
44+
lang: language,
45+
themes: {
46+
light: 'vitesse-light',
47+
dark: 'vitesse-dark',
48+
},
49+
});
50+
codeSig.value = str.toString();
4751
});
4852

4953
return (

0 commit comments

Comments
 (0)