Skip to content

Commit 3e8fc40

Browse files
authoredOct 9, 2024··
fix(client): use usePreferredDark with appearance: "force-auto" (#4263)
1 parent 6ea60f5 commit 3e8fc40

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed
 

‎src/client/app/data.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import siteData from '@siteData'
2-
import { useDark } from '@vueuse/core'
2+
import { useDark, usePreferredDark } from '@vueuse/core'
33
import {
44
computed,
55
inject,
@@ -79,13 +79,15 @@ export function initData(route: Route): VitePressData {
7979
const isDark =
8080
appearance === 'force-dark'
8181
? ref(true)
82-
: appearance
83-
? useDark({
84-
storageKey: APPEARANCE_KEY,
85-
initialValue: () => (appearance === 'dark' ? 'dark' : 'auto'),
86-
...(typeof appearance === 'object' ? appearance : {})
87-
})
88-
: ref(false)
82+
: appearance === 'force-auto'
83+
? usePreferredDark()
84+
: appearance
85+
? useDark({
86+
storageKey: APPEARANCE_KEY,
87+
initialValue: () => (appearance === 'dark' ? 'dark' : 'auto'),
88+
...(typeof appearance === 'object' ? appearance : {})
89+
})
90+
: ref(false)
8991

9092
const hashRef = ref(inBrowser ? location.hash : '')
9193

0 commit comments

Comments
 (0)
Please sign in to comment.