File tree Expand file tree Collapse file tree 2 files changed +19
-6
lines changed
routes/docs/_components/highlight Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,15 @@ export default component$(() => {
63
63
< meta charSet = "utf-8" />
64
64
< link rel = "manifest" href = "/manifest.json" />
65
65
< 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
+ />
66
75
</ head >
67
76
< body
68
77
lang = "en"
Original file line number Diff line number Diff line change @@ -3,11 +3,10 @@ import {
3
3
QwikIntrinsicElements ,
4
4
component$ ,
5
5
useSignal ,
6
- useTask $,
6
+ useVisibleTask $,
7
7
} from '@builder.io/qwik' ;
8
8
import { OmitSignalClass } from '@qwik-ui/utils' ;
9
9
import { CodeCopy } from '../code-copy/code-copy' ;
10
- import { getOrCreateHighlighter } from './get-or-create-highlighter' ;
11
10
12
11
export type HighlightProps = OmitSignalClass < QwikIntrinsicElements [ 'pre' ] > & {
13
12
code : string ;
@@ -28,8 +27,7 @@ export const Highlight = component$(
28
27
} : HighlightProps ) => {
29
28
const codeSig = useSignal ( '' ) ;
30
29
31
- useTask$ ( async function createHighlightedCode ( ) {
32
- const highlighter = await getOrCreateHighlighter ( ) ;
30
+ useVisibleTask$ ( async function createHighlightedCode ( ) {
33
31
let modifiedCode : string = code ;
34
32
35
33
let partsOfCode = modifiedCode . split ( splitCommentStart ) ;
@@ -42,8 +40,14 @@ export const Highlight = component$(
42
40
modifiedCode = partsOfCode [ 0 ] ;
43
41
}
44
42
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 ( ) ;
47
51
} ) ;
48
52
49
53
return (
You can’t perform that action at this time.
0 commit comments