pre-commit formatter
This commit is contained in:
parent
ddec81c876
commit
a1cd164e9a
117 changed files with 153 additions and 170 deletions
|
@ -23,7 +23,7 @@
|
|||
let currentTheme
|
||||
let switchButton
|
||||
let autoDefinedScheme = window.matchMedia('(prefers-color-scheme: dark)')
|
||||
|
||||
|
||||
function switchTheme(e) {
|
||||
currentTheme = (currentTheme === 'dark') ? 'light' : 'dark';
|
||||
if (localStorage) localStorage.setItem(STORAGE_KEY, currentTheme);
|
||||
|
@ -31,7 +31,7 @@
|
|||
changeGiscusTheme(currentTheme);
|
||||
document.body.dispatchEvent(new CustomEvent(currentTheme + "-theme-set"));
|
||||
}
|
||||
|
||||
|
||||
const autoChangeScheme = e => {
|
||||
currentTheme = e.matches ? 'dark' : 'light'
|
||||
document.documentElement.setAttribute('data-theme', currentTheme);
|
||||
|
@ -42,14 +42,14 @@
|
|||
document.addEventListener('DOMContentLoaded', function () {
|
||||
switchButton = document.querySelector('.theme-switcher')
|
||||
currentTheme = detectCurrentScheme()
|
||||
|
||||
|
||||
if (currentTheme === 'auto') {
|
||||
autoChangeScheme(autoDefinedScheme);
|
||||
autoDefinedScheme.addListener(autoChangeScheme);
|
||||
} else {
|
||||
document.documentElement.setAttribute('data-theme', currentTheme)
|
||||
}
|
||||
|
||||
|
||||
if (switchButton) {
|
||||
switchButton.addEventListener('click', switchTheme, false)
|
||||
}
|
||||
|
@ -72,13 +72,13 @@
|
|||
document.body.style.opacity = 1;
|
||||
}
|
||||
|
||||
function changeGiscusTheme (theme) {
|
||||
function changeGiscusTheme (theme) {
|
||||
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
|
||||
|
@ -86,4 +86,4 @@
|
|||
});
|
||||
}
|
||||
</script>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue