Skip to content

Commit 4cb2eb5

Browse files
authored
feat: set color scheme meta data value based on user settings (#689)
1 parent 7071ba5 commit 4cb2eb5

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

app/app.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ const localeMap = locales.value.reduce(
2121
{} as Record<string, Directions>,
2222
)
2323
24+
const darkMode = usePreferredDark()
25+
const colorMode = useColorMode()
26+
const colorScheme = computed(() => {
27+
return {
28+
system: darkMode ? 'dark light' : 'light dark',
29+
light: 'only light',
30+
dark: 'only dark',
31+
}[colorMode.preference]
32+
})
33+
2434
useHead({
2535
htmlAttrs: {
2636
'lang': () => locale.value,
@@ -30,6 +40,7 @@ useHead({
3040
titleTemplate: titleChunk => {
3141
return titleChunk ? titleChunk : 'npmx - Better npm Package Browser'
3242
},
43+
meta: [{ name: 'color-scheme', content: colorScheme }],
3344
})
3445
3546
if (import.meta.server) {

lunaria/styles.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,6 @@ export const CustomStyles = html`
301301
--ln-color-missing: var(--ln-color-black);
302302
--ln-color-outdated: #fb923c;
303303
--ln-color-done: #c084fc;
304-
305-
color-scheme: dark;
306304
}
307305
308306
html {

0 commit comments

Comments
 (0)