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 3737 --sidebar-accent-foreground : oklch (0.205 0 0 );
3838 --sidebar-border : oklch (0.922 0 0 );
3939 --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 );
4242 --layer-popover : 1000000 ;
4343}
4444
7474 --sidebar-accent-foreground : oklch (0.985 0 0 );
7575 --sidebar-border : oklch (1 0 0 / 10% );
7676 --sidebar-ring : oklch (0.556 0 0 );
77+ --code-background : oklch (0.225 0 0 );
78+ --code-foreground : oklch (0.875 0 0 );
7779}
7880
7981@theme inline {
Original file line number Diff line number Diff line change 88 import rehypeKatex from ' rehype-katex' ;
99 import rehypeStringify from ' rehype-stringify' ;
1010 import { copyCodeToClipboard } from ' $lib/utils/copy' ;
11- import ' highlight.js/styles/github-dark.css ' ;
11+ import { browser } from ' $app/environment ' ;
1212 import ' katex/dist/katex.min.css' ;
1313
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+
1418 interface Props {
1519 content: string ;
1620 class? : string ;
2125 let containerRef = $state <HTMLDivElement >();
2226 let processedHtml = $state (' ' );
2327
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+
2448 let processor = $derived (() => {
2549 return remark ()
2650 .use (remarkGfm ) // GitHub Flavored Markdown
You can’t perform that action at this time.
0 commit comments