use usePreferredDark with appearance: force-auto

pull/4263/head
Mike Bostock 12 months ago
parent 6ea60f5d0c
commit f8edd7c6b5
No known key found for this signature in database
GPG Key ID: C6817CA4CDEC8FDB

@ -1,5 +1,5 @@
import siteData from '@siteData' import siteData from '@siteData'
import { useDark } from '@vueuse/core' import { useDark, usePreferredDark } from '@vueuse/core'
import { import {
computed, computed,
inject, inject,
@ -79,13 +79,15 @@ export function initData(route: Route): VitePressData {
const isDark = const isDark =
appearance === 'force-dark' appearance === 'force-dark'
? ref(true) ? ref(true)
: appearance === 'force-auto'
? usePreferredDark()
: appearance : appearance
? useDark({ ? useDark({
storageKey: APPEARANCE_KEY, storageKey: APPEARANCE_KEY,
initialValue: () => (appearance === 'dark' ? 'dark' : 'auto'), initialValue: () => (appearance === 'dark' ? 'dark' : 'auto'),
...(typeof appearance === 'object' ? appearance : {}) ...(typeof appearance === 'object' ? appearance : {})
}) })
: ref(false) : ref(false)
const hashRef = ref(inBrowser ? location.hash : '') const hashRef = ref(inBrowser ? location.hash : '')

Loading…
Cancel
Save