Skip to content

Commit

Permalink
fix(theme): use document !== undefined check for browser (#2417)
Browse files Browse the repository at this point in the history
localStorage is defined on server in Deno
  • Loading branch information
brc-dd committed May 25, 2023
1 parent 06c0fc5 commit c869ea6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/client/theme-default/components/VPSwitchAppearance.vue
@@ -1,14 +1,14 @@
<script lang="ts" setup>
import { ref, onMounted, watch } from 'vue'
import { useData } from '../composables/data'
import { APPEARANCE_KEY } from '../../shared'
import { inBrowser, APPEARANCE_KEY } from '../../shared'
import VPSwitch from './VPSwitch.vue'
import VPIconSun from './icons/VPIconSun.vue'
import VPIconMoon from './icons/VPIconMoon.vue'
const { site, isDark } = useData()
const checked = ref(false)
const toggle = typeof localStorage !== 'undefined' ? useAppearance() : () => {}
const toggle = inBrowser ? useAppearance() : () => {}
onMounted(() => {
checked.value = document.documentElement.classList.contains('dark')
Expand Down

0 comments on commit c869ea6

Please sign in to comment.