File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change 4
4
< script >
5
5
( function ( ) {
6
6
try {
7
+ // Check for stored theme
7
8
const storedTheme = localStorage . getItem ( 'theme' ) ;
8
- if ( storedTheme ) {
9
- document . documentElement . setAttribute ( 'data-theme' , storedTheme ) ;
9
+ const theme = storedTheme || ( window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches ? 'dark' : 'light' ) ;
10
+
11
+ // Set Bootstrap theme attribute
12
+ document . documentElement . setAttribute ( 'data-bs-theme' , theme ) ;
13
+
14
+ // If dark theme, inject Darkly CSS immediately to prevent flash
15
+ if ( theme === 'dark' ) {
16
+ const darkThemeLink = document . createElement ( 'link' ) ;
17
+ darkThemeLink . rel = 'stylesheet' ;
18
+ darkThemeLink . href = 'https://bootswatch.com/5/darkly/bootstrap.css' ;
19
+ darkThemeLink . integrity = 'sha384-mXM+8P9BUwTXMBS6pzZaBva0g/sZsdn7ZdBimWWpF/1K2kVhkyjQrBznOTf31ui7' ;
20
+ darkThemeLink . crossOrigin = 'anonymous' ;
21
+ darkThemeLink . setAttribute ( 'data-theme' , 'dark' ) ;
22
+ document . head . appendChild ( darkThemeLink ) ;
10
23
}
11
24
} catch ( e ) {
12
25
console . error ( 'Could not apply theme from localStorage' , e ) ;
18
31
< body data-sveltekit-preload-data ="hover ">
19
32
< div style ="display: contents "> %sveltekit.body%</ div >
20
33
</ body >
21
- </ html >
34
+ </ html >
Original file line number Diff line number Diff line change 33
33
<link rel ="apple-touch-icon" sizes ="180x180" href =" {assets }/favicon/apple-touch-icon.png" />
34
34
<link rel ="manifest" href =" {assets }/favicon/site.webmanifest" />
35
35
36
+ <!-- Bootstrap CSS -->
37
+ <link
38
+ rel =" stylesheet"
39
+ href =
" https://cdn.jsdelivr.net/npm/[email protected] /dist/css/bootstrap.min.css"
40
+ integrity =" sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
41
+ crossorigin =" anonymous" />
42
+
36
43
<!-- Bootswatch: Darkly theme -->
37
44
<link
38
45
rel =" stylesheet"
You can’t perform that action at this time.
0 commit comments