Dark mode for Pygments
This commit is contained in:
parent
543ae58a37
commit
91aa9016e7
1 changed files with 10 additions and 0 deletions
|
@ -20,7 +20,17 @@
|
||||||
if (theme === 'browser') {
|
if (theme === 'browser') {
|
||||||
theme = darkSchemeWatch.matches ? 'dark' : 'light';
|
theme = darkSchemeWatch.matches ? 'dark' : 'light';
|
||||||
}
|
}
|
||||||
|
const pygmentsTheme = theme === 'light'
|
||||||
|
? '{{ PYGMENTS_STYLE }}'
|
||||||
|
: '{{ PYGMENTS_STYLE_DARK or PYGMENTS_STYLE }}'
|
||||||
console.log(`Switching theme to ${theme}.`)
|
console.log(`Switching theme to ${theme}.`)
|
||||||
|
|
||||||
|
Array.from(document.head.getElementsByTagName('link')).forEach(linkEl => {
|
||||||
|
if (linkEl.href.match(/\/theme\/pygments\/.*\.min\.css/)) {
|
||||||
|
linkEl.href = `/theme/pygments/${pygmentsTheme}.min.css`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (theme === 'dark') {
|
if (theme === 'dark') {
|
||||||
document.body.classList.add('dark_theme');
|
document.body.classList.add('dark_theme');
|
||||||
document.body.classList.remove('light_theme');
|
document.body.classList.remove('light_theme');
|
||||||
|
|
Loading…
Reference in a new issue