Add a couple comments

This commit is contained in:
Sumner Evans 2020-04-07 22:16:41 -06:00
parent 91aa9016e7
commit 6816d4800b
No known key found for this signature in database
GPG key ID: 8904527AB50022FD

View file

@ -20,11 +20,13 @@
if (theme === 'browser') { if (theme === 'browser') {
theme = darkSchemeWatch.matches ? 'dark' : 'light'; theme = darkSchemeWatch.matches ? 'dark' : 'light';
} }
console.log(`Switching theme to ${theme}.`)
// Find the pygments CSS file and change it to the theme specified in the
// config.
const pygmentsTheme = theme === 'light' const pygmentsTheme = theme === 'light'
? '{{ PYGMENTS_STYLE }}' ? '{{ PYGMENTS_STYLE }}'
: '{{ PYGMENTS_STYLE_DARK or PYGMENTS_STYLE }}' : '{{ PYGMENTS_STYLE_DARK or PYGMENTS_STYLE }}'
console.log(`Switching theme to ${theme}.`)
Array.from(document.head.getElementsByTagName('link')).forEach(linkEl => { Array.from(document.head.getElementsByTagName('link')).forEach(linkEl => {
if (linkEl.href.match(/\/theme\/pygments\/.*\.min\.css/)) { if (linkEl.href.match(/\/theme\/pygments\/.*\.min\.css/)) {
linkEl.href = `/theme/pygments/${pygmentsTheme}.min.css`; linkEl.href = `/theme/pygments/${pygmentsTheme}.min.css`;
@ -32,11 +34,11 @@
}); });
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');
} else { } else {
document.body.classList.add('light_theme'); document.body.classList.add('light-theme');
document.body.classList.remove('dark_theme'); document.body.classList.remove('dark-theme');
} }
} }