Skip to content

Commit 9e1f90b

Browse files
committed
added view transitions to theme switcher
1 parent f83eb1a commit 9e1f90b

7 files changed

Lines changed: 762 additions & 7 deletions

File tree

astro.config.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,16 @@ export default defineConfig({
8787
content: "index, follow",
8888
},
8989
},
90+
{
91+
tag: "script",
92+
attrs: { type: "module" },
93+
content: `
94+
document.addEventListener('starlight:theme-change', (e) => {
95+
e.preventDefault();
96+
const { theme, resolvedTheme } = e.detail;
97+
document.startViewTransition({types: ['light-dark'], update: () => (document.documentElement.dataset.theme = resolvedTheme)});
98+
});`,
99+
},
90100
{
91101
tag: "meta",
92102
attrs: {
@@ -169,7 +179,7 @@ export default defineConfig({
169179
&& !page.startsWith('https://vtbag.dev/basics/hide-and-seek/list-')
170180
&& !page.startsWith('https://vtbag.dev/basics/hide-and-seek/list/')
171181
&& !page.startsWith('https://vtbag.dev/basics/hide-and-seek/problem/')
172-
&& !page.startsWith('https://vtbag.dev/basics/hide-and-seek/solution/')
182+
&& !page.startsWith('https://vtbag.dev/basics/hide-and-seek/solution/')
173183
&& !page.startsWith('https://vtbag.dev/basics/pseudos-')
174184
&& !page.startsWith('https://vtbag.dev/crossing/')
175185
&& !page.startsWith('https://vtbag.dev/tests/')
@@ -189,7 +199,19 @@ export default defineConfig({
189199
allow: [".."],
190200
},
191201
allowedHosts: [".trycloudflare.com"],
192-
} /*
202+
},
203+
optimizeDeps: {
204+
205+
include: [
206+
'unified',
207+
'remark-parse',
208+
'remark-rehype',
209+
'rehype-stringify',
210+
'rehype-expressive-code',
211+
'@expressive-code/core' // Covers Shiki/plugin deps
212+
]
213+
}
214+
/*
193215
plugins: [visualizer({
194216
brotliSize: true
195217
})]*/,
@@ -201,7 +223,7 @@ function sidebar() {
201223
{
202224
label: "@vtbag",
203225
link: "/vtbag/",
204-
},
226+
},
205227
{
206228
label: "Basic Information",
207229
items: [

0 commit comments

Comments
 (0)