-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: update workflows config. 542210c
- Loading branch information
1 parent
5695e67
commit 0302439
Showing
4 changed files
with
180 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
;(() => { | ||
const targetElement = document.documentElement; | ||
const defaultTheme = targetElement.getAttribute("data-color-mode"); | ||
changeGiscusTheme(defaultTheme) | ||
const observer = new MutationObserver((mutationsList, observer) => { | ||
for(const mutation of mutationsList) { | ||
if (mutation.type === 'attributes') { | ||
const value = targetElement.getAttribute("data-color-mode"); | ||
changeGiscusTheme(value) | ||
} | ||
} | ||
}); | ||
|
||
observer.observe(targetElement, { | ||
attributes: 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) | ||
} | ||
} | ||
})(); |
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