From f8edd7c6b55d0e5ca1122f8fafeab394faa45c2e Mon Sep 17 00:00:00 2001 From: Mike Bostock Date: Wed, 9 Oct 2024 10:27:48 -0700 Subject: [PATCH 1/2] use usePreferredDark with appearance: force-auto --- src/client/app/data.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/client/app/data.ts b/src/client/app/data.ts index 67fc0942f44d..146d87426794 100644 --- a/src/client/app/data.ts +++ b/src/client/app/data.ts @@ -1,5 +1,5 @@ import siteData from '@siteData' -import { useDark } from '@vueuse/core' +import { useDark, usePreferredDark } from '@vueuse/core' import { computed, inject, @@ -79,13 +79,15 @@ export function initData(route: Route): VitePressData { const isDark = appearance === 'force-dark' ? ref(true) + : appearance === 'force-auto' + ? usePreferredDark() : appearance - ? useDark({ - storageKey: APPEARANCE_KEY, - initialValue: () => (appearance === 'dark' ? 'dark' : 'auto'), - ...(typeof appearance === 'object' ? appearance : {}) - }) - : ref(false) + ? useDark({ + storageKey: APPEARANCE_KEY, + initialValue: () => (appearance === 'dark' ? 'dark' : 'auto'), + ...(typeof appearance === 'object' ? appearance : {}) + }) + : ref(false) const hashRef = ref(inBrowser ? location.hash : '') From 9f6f373e73be866d652f4a1055054b98a92de20a Mon Sep 17 00:00:00 2001 From: Mike Bostock Date: Wed, 9 Oct 2024 10:37:00 -0700 Subject: [PATCH 2/2] prettier --- src/client/app/data.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/client/app/data.ts b/src/client/app/data.ts index 146d87426794..c99de52fc039 100644 --- a/src/client/app/data.ts +++ b/src/client/app/data.ts @@ -80,14 +80,14 @@ export function initData(route: Route): VitePressData { appearance === 'force-dark' ? ref(true) : appearance === 'force-auto' - ? usePreferredDark() - : appearance - ? useDark({ - storageKey: APPEARANCE_KEY, - initialValue: () => (appearance === 'dark' ? 'dark' : 'auto'), - ...(typeof appearance === 'object' ? appearance : {}) - }) - : ref(false) + ? usePreferredDark() + : appearance + ? useDark({ + storageKey: APPEARANCE_KEY, + initialValue: () => (appearance === 'dark' ? 'dark' : 'auto'), + ...(typeof appearance === 'object' ? appearance : {}) + }) + : ref(false) const hashRef = ref(inBrowser ? location.hash : '')