From cfe66c59fddbc581d373c803393e33877c679937 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 9 May 2024 00:37:01 +0000 Subject: [PATCH] v1.2.0 fix: Add css file to exports map #3 36cae22ff129675c0d544d7efeb59dac92f2d7fd --- badges.svg | 8 ++++---- index.html | 24 ++++++++++++------------ js/giscus.js | 34 ++++++++++++++++++++++++++++++++++ lcov-report/index.html | 2 +- lcov-report/index.ts.html | 2 +- 5 files changed, 52 insertions(+), 18 deletions(-) create mode 100644 js/giscus.js diff --git a/badges.svg b/badges.svg index b3d1862..27fadff 100644 --- a/badges.svg +++ b/badges.svg @@ -1,14 +1,14 @@ coverage: 100% - + - - + + - + - - - - - - + + + + + + - - - + + + top
@@ -392,14 +392,14 @@

- + - + diff --git a/js/giscus.js b/js/giscus.js new file mode 100644 index 0000000..729dd0b --- /dev/null +++ b/js/giscus.js @@ -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) + } + } +})(); diff --git a/lcov-report/index.html b/lcov-report/index.html index f09571b..c802587 100644 --- a/lcov-report/index.html +++ b/lcov-report/index.html @@ -101,7 +101,7 @@

All files