Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit be565ba

Browse files
committed
fix(theme): fix ssr compile error
1 parent aa6168c commit be565ba

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

theme/src/client/components/Home/VPHomeHero.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ function noTransition() {
4646
4747
let defaultTheme: string | undefined
4848
watch(() => props.forceDark, () => {
49-
if (inBrowser && props.forceDark) {
49+
if (!inBrowser || __VUEPRESS_SSR__)
50+
return
51+
if (props.forceDark) {
5052
defaultTheme ??= document.documentElement.dataset.theme
5153
document.documentElement.dataset.theme = 'dark'
5254
document.documentElement.classList.add('force-dark')

theme/src/client/composables/css-var.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function useCssVar(
1515

1616
function updateCssVar() {
1717
const _window = typeof window ? window : null
18-
const target = _window?.document.documentElement
18+
const target = _window?.document?.documentElement
1919
const key = toValue(prop)
2020
if (target && key) {
2121
const value = _window.getComputedStyle(target).getPropertyValue(key)?.trim()

0 commit comments

Comments
 (0)