Skip to content

Commit efdb234

Browse files
committed
docs(shiki) use strategy 'intersection-observer' in dev mode
1 parent 27488e1 commit efdb234

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

apps/website/src/components/highlight/highlight.tsx

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import { CodeCopy } from '../code-copy/code-copy';
1111
import { getHighlighterCore } from 'shiki';
1212
import { cn } from '@qwik-ui/utils';
1313
import { isDev } from '@builder.io/qwik/build';
14+
import poimandres from 'shiki/themes/poimandres.mjs';
15+
import html from 'shiki/langs/html.mjs';
16+
import css from 'shiki/langs/css.mjs';
17+
import tsx from 'shiki/langs/tsx.mjs';
1418

1519
export type HighlightProps = PropsOf<'div'> & {
1620
code: string;
@@ -31,11 +35,6 @@ export const Highlight = component$(
3135
}: HighlightProps) => {
3236
const codeSig = useSignal('');
3337

34-
useVisibleTask$(({ track }) => {
35-
track(() => codeSig.value);
36-
console.log('codeSig changed: ', codeSig.value);
37-
});
38-
3938
const addShiki$ = $(async () => {
4039
let modifiedCode: string = code;
4140

@@ -50,15 +49,8 @@ export const Highlight = component$(
5049
}
5150

5251
const highlighter = await getHighlighterCore({
53-
themes: [
54-
// or a dynamic import if you want to do chunk splitting
55-
import('shiki/themes/poimandres.mjs'),
56-
],
57-
langs: [
58-
import('shiki/langs/html.mjs'),
59-
import('shiki/langs/tsx.mjs'),
60-
import('shiki/langs/css.mjs'),
61-
],
52+
themes: [poimandres],
53+
langs: [html, css, tsx],
6254
loadWasm: import('shiki/wasm'),
6355
});
6456

@@ -87,7 +79,7 @@ export const Highlight = component$(
8779
await addShiki$();
8880
}
8981
},
90-
{ strategy: 'document-ready' },
82+
{ strategy: 'intersection-observer' },
9183
);
9284

9385
return (

0 commit comments

Comments
 (0)