File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change 37
37
--sidebar-accent-foreground : oklch (0.205 0 0 );
38
38
--sidebar-border : oklch (0.922 0 0 );
39
39
--sidebar-ring : oklch (0.708 0 0 );
40
- --code-background : oklch (0.225 0 0 );
41
- --code-foreground : oklch (0.875 0 0 );
40
+ --code-background : oklch (0.975 0 0 );
41
+ --code-foreground : oklch (0.145 0 0 );
42
42
--layer-popover : 1000000 ;
43
43
}
44
44
74
74
--sidebar-accent-foreground : oklch (0.985 0 0 );
75
75
--sidebar-border : oklch (1 0 0 / 10% );
76
76
--sidebar-ring : oklch (0.556 0 0 );
77
+ --code-background : oklch (0.225 0 0 );
78
+ --code-foreground : oklch (0.875 0 0 );
77
79
}
78
80
79
81
@theme inline {
Original file line number Diff line number Diff line change 8
8
import rehypeKatex from ' rehype-katex' ;
9
9
import rehypeStringify from ' rehype-stringify' ;
10
10
import { copyCodeToClipboard } from ' $lib/utils/copy' ;
11
- import ' highlight.js/styles/github-dark.css ' ;
11
+ import { browser } from ' $app/environment ' ;
12
12
import ' katex/dist/katex.min.css' ;
13
13
14
+ import githubDarkCss from ' highlight.js/styles/github-dark.css?inline' ;
15
+ import githubLightCss from ' highlight.js/styles/github.css?inline' ;
16
+ import { mode } from ' mode-watcher' ;
17
+
14
18
interface Props {
15
19
content: string ;
16
20
class? : string ;
21
25
let containerRef = $state <HTMLDivElement >();
22
26
let processedHtml = $state (' ' );
23
27
28
+ function loadHighlightTheme(isDark : boolean ) {
29
+ if (! browser ) return ;
30
+
31
+ const existingThemes = document .querySelectorAll (' style[data-highlight-theme]' );
32
+ existingThemes .forEach ((style ) => style .remove ());
33
+
34
+ const style = document .createElement (' style' );
35
+ style .setAttribute (' data-highlight-theme' , ' true' );
36
+ style .textContent = isDark ? githubDarkCss : githubLightCss ;
37
+
38
+ document .head .appendChild (style );
39
+ }
40
+
41
+ $effect (() => {
42
+ const currentMode = mode .current ;
43
+ const isDark = currentMode === ' dark' ;
44
+
45
+ loadHighlightTheme (isDark );
46
+ });
47
+
24
48
let processor = $derived (() => {
25
49
return remark ()
26
50
.use (remarkGfm ) // GitHub Flavored Markdown
You can’t perform that action at this time.
0 commit comments