-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update .gitattributes 31855f2
- Loading branch information
1 parent
8675e74
commit d9b801f
Showing
11 changed files
with
158 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
;(() => { | ||
(() => { | ||
const targetElement = document.documentElement; | ||
const defaultTheme = targetElement.getAttribute("data-color-mode"); | ||
changeGiscusTheme(defaultTheme) | ||
const defaultTheme = targetElement.getAttribute('data-color-mode'); | ||
changeGiscusTheme(defaultTheme); | ||
const observer = new MutationObserver((mutationsList, observer) => { | ||
for(const mutation of mutationsList) { | ||
for (const mutation of mutationsList) { | ||
if (mutation.type === 'attributes') { | ||
const value = targetElement.getAttribute("data-color-mode"); | ||
changeGiscusTheme(value) | ||
const value = targetElement.getAttribute('data-color-mode'); | ||
changeGiscusTheme(value); | ||
} | ||
} | ||
}); | ||
|
||
observer.observe(targetElement, { | ||
attributes: true, | ||
attributeOldValue: true | ||
attributeOldValue: true, | ||
}); | ||
function changeGiscusTheme(theme = "light") { | ||
const iframe = document.querySelector('.giscus-frame'); | ||
if (iframe) { | ||
const config = { | ||
giscus: { | ||
setConfig: { | ||
theme: theme.toLocaleLowerCase(), | ||
}, | ||
} | ||
}; | ||
iframe.contentWindow.postMessage(config, 'https://giscus.app'); | ||
const script = document.querySelector("script[data-script-id=\"giscus\"]") | ||
script.setAttribute("data-theme", theme) | ||
} | ||
|
||
function changeGiscusTheme(theme = 'light') { | ||
const iframe = document.querySelector('.giscus-frame'); | ||
if (iframe) { | ||
const config = { | ||
giscus: { | ||
setConfig: { | ||
theme: theme.toLocaleLowerCase(), | ||
}, | ||
}, | ||
}; | ||
iframe.contentWindow.postMessage(config, 'https://giscus.app'); | ||
const script = document.querySelector('script[data-script-id="giscus"]'); | ||
script.setAttribute('data-theme', theme); | ||
} | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.