Skip to content

Commit 1a46641

Browse files
authored
docs: dark mode not applied properly in landing page (#2093)
1 parent 09a14f0 commit 1a46641

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

.vitepress/theme/styles/landing.css

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,11 @@
44

55
html:has(.landing) {
66
--vp-c-bg: #101010;
7-
87
background-color: #101010;
9-
10-
body {
11-
background-color: #101010;
12-
}
138
}
149

1510
.landing {
1611
overflow-x: hidden;
17-
background-color: #101010;
1812

1913
* {
2014
-webkit-font-smoothing: antialiased !important;

index.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
title: Vite
33
titleTemplate: 次世代フロントエンドツール
4+
# add `dark` here to apply dark mode on initial load,
5+
# since `onMounted` doesn't run during SSR
46
pageClass: landing dark
57

68
layout: home
@@ -10,6 +12,9 @@ markdownStyles: false
1012
---
1113

1214
<script setup>
15+
import { useData } from 'vitepress'
16+
import { onBeforeUnmount, onMounted, ref } from 'vue'
17+
1318
import Hero from '.vitepress/theme/components/landing/1. hero-section/HeroSection.vue'
1419
import FeatureSection from './.vitepress/theme/components/landing/2. feature-section/FeatureSection.vue'
1520
import FrameworksSection from './.vitepress/theme/components/landing/3. frameworks-section/FrameworksSection.vue'
@@ -24,6 +29,16 @@ import FeatureFlexiblePlugins from './.vitepress/theme/components/landing/2. fea
2429
import FeatureTypedAPI from './.vitepress/theme/components/landing/2. feature-section/FeatureTypedAPI.vue'
2530
import FeatureSSRSupport from './.vitepress/theme/components/landing/2. feature-section/FeatureSSRSupport.vue'
2631
import FeatureCI from './.vitepress/theme/components/landing/2. feature-section/FeatureCI.vue'
32+
33+
const { isDark } = useData()
34+
35+
onMounted(() => {
36+
document.documentElement.classList.add('dark')
37+
})
38+
39+
onBeforeUnmount(() => {
40+
document.documentElement.classList.toggle('dark', isDark.value)
41+
})
2742
</script>
2843

2944
<div class="VPHome">

0 commit comments

Comments
 (0)