chore(deps): update dependency refs-cli to v1.5.1 c407dce74b

This commit is contained in:
jaywcjlove
2023-09-11 12:03:56 +00:00
parent 0b4343d9fe
commit fe1aa4cd3c
154 changed files with 320 additions and 302 deletions

View File

@ -1,7 +1,17 @@
const LOCAL_NANE = '_dark_mode_theme_';
const rememberedValue = localStorage.getItem(LOCAL_NANE);
if (rememberedValue && ['light', 'dark'].includes(rememberedValue)) {
document.documentElement.setAttribute('data-color-mode', rememberedValue);
const iframe = document.querySelector('.giscus-frame');
if (iframe) {
const config = {
setConfig: {
theme: rememberedValue.toLocaleLowerCase(),
},
};
iframe.contentWindow.postMessage({ giscus: config }, 'https://giscus.app');
}
}
const button = document.querySelector('#darkMode');
button.onclick = () => {
@ -9,4 +19,11 @@ button.onclick = () => {
const mode = theme === 'light' ? 'dark' : 'light';
document.documentElement.setAttribute('data-color-mode', mode);
localStorage.setItem(LOCAL_NANE, mode);
const iframe = document.querySelector('.giscus-frame');
if (iframe) {
const config = {
setConfig: { theme: mode },
};
iframe.contentWindow.postMessage({ giscus: config }, 'https://giscus.app');
}
};