Skip to content

Commit 5b64150

Browse files
authored
Fix inline theme script HTML escaping (#2809)
Fixes JavaScript syntax error on all pages caused by the inline theme script being HTML-escaped (`'` → `'`). Use dangerouslySetInnerHTML to prevent escaping.
1 parent 87f5e97 commit 5b64150

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

_includes/layout.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ export default function Layout(data: Lume.Data) {
2525
<meta name="description" content={data.description} />}
2626
<link rel="icon" href="/favicon.ico" />
2727
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
28-
<script>
29-
const theme = localStorage.getItem('denoDocsTheme') ||
30-
(window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' :
31-
'light'); document.documentElement.classList.add(theme);
32-
</script>
28+
<script
29+
dangerouslySetInnerHTML={{
30+
__html:
31+
`const theme = localStorage.getItem('denoDocsTheme') || (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'); document.documentElement.classList.add(theme);`,
32+
}}
33+
/>
3334

3435
<link
3536
rel="stylesheet"

0 commit comments

Comments
 (0)