Update to current version
All checks were successful
Building & Deploying Website / Deploy-Website (push) Successful in 12s
All checks were successful
Building & Deploying Website / Deploy-Website (push) Successful in 12s
This commit is contained in:
@@ -34,6 +34,62 @@ function setTheme(theme) {
|
||||
body.classList.remove('colorscheme-' + inverse);
|
||||
body.classList.add('colorscheme-' + theme);
|
||||
document.documentElement.style['color-scheme'] = theme;
|
||||
|
||||
function waitForElm(selector) {
|
||||
return new Promise(resolve => {
|
||||
if (document.querySelector(selector)) {
|
||||
return resolve(document.querySelector(selector));
|
||||
}
|
||||
|
||||
const observer = new MutationObserver(mutations => {
|
||||
if (document.querySelector(selector)) {
|
||||
resolve(document.querySelector(selector));
|
||||
observer.disconnect();
|
||||
}
|
||||
});
|
||||
|
||||
observer.observe(document.body, {
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (theme === 'dark') {
|
||||
const message = {
|
||||
type: 'set-theme',
|
||||
theme: 'github-dark'
|
||||
};
|
||||
waitForElm('.utterances-frame').then((iframe) => {
|
||||
iframe.contentWindow.postMessage(message, 'https://utteranc.es');
|
||||
})
|
||||
|
||||
}
|
||||
else {
|
||||
const message = {
|
||||
type: 'set-theme',
|
||||
theme: 'github-light'
|
||||
};
|
||||
waitForElm('.utterances-frame').then((iframe) => {
|
||||
iframe.contentWindow.postMessage(message, 'https://utteranc.es');
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
function sendMessage(message) {
|
||||
const iframe = document.querySelector('iframe.giscus-frame');
|
||||
if (!iframe) return;
|
||||
iframe.contentWindow.postMessage({ giscus: message }, 'https://giscus.app');
|
||||
}
|
||||
sendMessage({
|
||||
setConfig: {
|
||||
theme: theme,
|
||||
},
|
||||
});
|
||||
|
||||
// Create and send event
|
||||
const event = new Event('themeChanged');
|
||||
document.dispatchEvent(event);
|
||||
}
|
||||
|
||||
function rememberTheme(theme) {
|
||||
|
||||
3
themes/hugo-coder/assets/js/purify.min.js
vendored
Normal file
3
themes/hugo-coder/assets/js/purify.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user