Skip to content

Commit

Permalink
fix(client): use usePreferredDark with appearance: "force-auto" (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock authored Oct 9, 2024
1 parent 6ea60f5 commit 3e8fc40
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/client/app/data.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import siteData from '@siteData'
import { useDark } from '@vueuse/core'
import { useDark, usePreferredDark } from '@vueuse/core'
import {
computed,
inject,
Expand Down Expand Up @@ -79,13 +79,15 @@ export function initData(route: Route): VitePressData {
const isDark =
appearance === 'force-dark'
? ref(true)
: appearance
? useDark({
storageKey: APPEARANCE_KEY,
initialValue: () => (appearance === 'dark' ? 'dark' : 'auto'),
...(typeof appearance === 'object' ? appearance : {})
})
: ref(false)
: appearance === 'force-auto'
? usePreferredDark()
: appearance
? useDark({
storageKey: APPEARANCE_KEY,
initialValue: () => (appearance === 'dark' ? 'dark' : 'auto'),
...(typeof appearance === 'object' ? appearance : {})
})
: ref(false)

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

Expand Down

0 comments on commit 3e8fc40

Please sign in to comment.