File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
src/resources/formats/html Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change 44function loadGiscusWhenReady () {
55 // Function to get the theme based on body class
66 const getTheme = () => {
7- const baseTheme = document .getElementById (' giscus-base-theme' ).value ;
8- const altTheme = document .getElementById (' giscus-alt-theme' ).value ;
7+ let baseTheme = document .getElementById (' giscus-base-theme' ).value ;
8+ let altTheme = document .getElementById (' giscus-alt-theme' ).value ;
9+ if (authorPrefersDark) {
10+ [baseTheme, altTheme] = [altTheme, baseTheme];
11+ }
912 return document .body .classList .contains (' quarto-dark' ) ? altTheme : baseTheme;
1013 };
1114
Original file line number Diff line number Diff line change 136136
137137 let newTheme = ' ' ;
138138
139- if (darkModeDefault ) {
139+ if (authorPrefersDark ) {
140140 newTheme = isAlternate ? baseTheme : alternateTheme;
141141 } else {
142142 newTheme = isAlternate ? alternateTheme : baseTheme;
165165 };
166166
167167 < % if (respectUserColorScheme) { % >
168+ const authorPrefersDark = < %= darkModeDefault % > ;
168169 const queryPrefersDark = window .matchMedia (' (prefers-color-scheme: dark)' );
169170 const darkModeDefault = queryPrefersDark .matches ;
170171 < % } else { % >
171172 const darkModeDefault = < %= darkModeDefault % > ;
173+ const authorPrefersDark = < %= darkModeDefault % > ;
172174 < % } % >
173175
174176 < % if (! darkModeDefault) { % >
You can’t perform that action at this time.
0 commit comments