-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 15df8e9
Showing
174 changed files
with
1,649,364 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
document$.subscribe(function() { | ||
updateTheme(); // Update theme on AJAX page navigation | ||
}); | ||
|
||
const lightModeStyle = '/assets/stylesheets/pygments/default.css'; | ||
const darkModeStyle = '/assets/stylesheets/pygments/github-dark.css'; | ||
|
||
function switchStyle(isDarkMode) { | ||
const desiredStyle = isDarkMode ? darkModeStyle : lightModeStyle; | ||
let pygmentsStyle = document.getElementById('pygments-style'); | ||
|
||
if (!pygmentsStyle) { | ||
pygmentsStyle = document.createElement('link'); | ||
pygmentsStyle.id = 'pygments-style'; | ||
pygmentsStyle.rel = 'stylesheet'; | ||
pygmentsStyle.type = 'text/css'; | ||
document.body.appendChild(pygmentsStyle); | ||
} | ||
|
||
// Only update the href if it's different from the desired style | ||
if (pygmentsStyle.href.split('/').pop() !== desiredStyle.split('/').pop()) { | ||
pygmentsStyle.href = desiredStyle; | ||
} | ||
} | ||
|
||
function updateTheme() { | ||
const isDarkMode = document.body.getAttribute('data-md-color-scheme') === 'slate'; | ||
switchStyle(isDarkMode); | ||
} | ||
|
||
// MutationObserver for theme changes | ||
const observer = new MutationObserver(mutations => { | ||
mutations.forEach(mutation => { | ||
if (mutation.attributeName === 'data-md-color-scheme') { | ||
updateTheme(); | ||
} | ||
}); | ||
}); | ||
|
||
observer.observe(document.body, { attributes: true }); | ||
|
||
// Initial theme update | ||
updateTheme(); |
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.