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 44 < script >
55 ( function ( ) {
66 try {
7+ // Check for stored theme
78 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 ) ;
1023 }
1124 } catch ( e ) {
1225 console . error ( 'Could not apply theme from localStorage' , e ) ;
1831 < body data-sveltekit-preload-data ="hover ">
1932 < div style ="display: contents "> %sveltekit.body%</ div >
2033 </ body >
21- </ html >
34+ </ html >
Original file line number Diff line number Diff line change 3333 <link rel ="apple-touch-icon" sizes ="180x180" href =" {assets }/favicon/apple-touch-icon.png" />
3434 <link rel ="manifest" href =" {assets }/favicon/site.webmanifest" />
3535
36+ <!-- Bootstrap CSS -->
37+ <link
38+ rel =" stylesheet"
39+ href =" https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
40+ integrity =" sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
41+ crossorigin =" anonymous" />
42+
3643 <!-- Bootswatch: Darkly theme -->
3744 <link
3845 rel =" stylesheet"
You can’t perform that action at this time.
0 commit comments