fix(theme): force update title attribute on hydration

closes #4004
pull/3901/merge
Divyansh Singh 6 months ago
parent 143b1e91f3
commit d348da770c

@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { inject, computed } from 'vue' import { inject, ref, watchPostEffect } from 'vue'
import { useData } from '../composables/data' import { useData } from '../composables/data'
import VPSwitch from './VPSwitch.vue' import VPSwitch from './VPSwitch.vue'
@ -9,8 +9,10 @@ const toggleAppearance = inject('toggle-appearance', () => {
isDark.value = !isDark.value isDark.value = !isDark.value
}) })
const switchTitle = computed(() => { const switchTitle = ref('')
return isDark.value
watchPostEffect(() => {
switchTitle.value = isDark.value
? theme.value.lightModeSwitchTitle || 'Switch to light theme' ? theme.value.lightModeSwitchTitle || 'Switch to light theme'
: theme.value.darkModeSwitchTitle || 'Switch to dark theme' : theme.value.darkModeSwitchTitle || 'Switch to dark theme'
}) })

Loading…
Cancel
Save