File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
packages/docusaurus-theme-classic/src Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import path from 'path';
9
9
import { createRequire } from 'module' ;
10
10
import rtlcss from 'rtlcss' ;
11
11
import { readDefaultCodeTranslationMessages } from '@docusaurus/theme-translations' ;
12
+ import { generateScriptForSSR } from 'prism-react-renderer' ;
12
13
import { getTranslationFiles , translateThemeConfig } from './translations' ;
13
14
import type { LoadContext , Plugin } from '@docusaurus/types' ;
14
15
import type { ThemeConfig } from '@docusaurus/theme-common' ;
@@ -107,7 +108,7 @@ export default function themeClassic(
107
108
const {
108
109
announcementBar,
109
110
colorMode,
110
- prism : { additionalLanguages} ,
111
+ prism : { additionalLanguages, theme , darkTheme } ,
111
112
} = themeConfig ;
112
113
const { customCss} = options ;
113
114
const { direction} = localeConfigs [ currentLocale ] ! ;
@@ -198,6 +199,17 @@ ${noFlashColorMode(colorMode)}
198
199
${ announcementBar ? AnnouncementBarInlineJavaScript : '' }
199
200
` ,
200
201
} ,
202
+ {
203
+ tagName : 'script' ,
204
+ innerHTML : generateScriptForSSR (
205
+ [ theme , darkTheme ] ,
206
+ `() => (
207
+ document.documentElement.getAttribute('data-theme') === 'dark'
208
+ ? ${ darkTheme . id }
209
+ : ${ theme . id }
210
+ )` ,
211
+ ) ,
212
+ } ,
201
213
] ,
202
214
} ;
203
215
} ,
You can’t perform that action at this time.
0 commit comments