|
| 1 | +--- |
| 2 | +
|
| 3 | +--- |
| 4 | + |
| 5 | +<script |
| 6 | + is:inline |
| 7 | + src="https://giscus.app/client.js" |
| 8 | + data-repo="FireIsGood/fireis.dev" |
| 9 | + data-repo-id="R_kgDOLy6p6g" |
| 10 | + data-category="Announcements" |
| 11 | + data-category-id="DIC_kwDOLy6p6s4ClW6P" |
| 12 | + data-mapping="pathname" |
| 13 | + data-strict="0" |
| 14 | + data-reactions-enabled="1" |
| 15 | + data-emit-metadata="0" |
| 16 | + data-input-position="bottom" |
| 17 | + data-theme="light" |
| 18 | + data-lang="en" |
| 19 | + data-loading="lazy" |
| 20 | + crossorigin="anonymous" |
| 21 | + async></script> |
| 22 | + |
| 23 | +<script is:inline> |
| 24 | + function updateGiscusTheme() { |
| 25 | + const themeMapping = { |
| 26 | + light: "light", |
| 27 | + dark: "dark_dimmed", |
| 28 | + }; |
| 29 | + const theme = themeMapping[document.documentElement.getAttribute("data-theme")]; |
| 30 | + const iframe = document.querySelector("iframe.giscus-frame"); |
| 31 | + if (!iframe) return; |
| 32 | + iframe.contentWindow.postMessage({ giscus: { setConfig: { theme } } }, "https://giscus.app"); |
| 33 | + } |
| 34 | + |
| 35 | + // Update if the theme changes |
| 36 | + const observer = new MutationObserver(updateGiscusTheme); |
| 37 | + observer.observe(document.documentElement, { attributes: true, attributeFilter: ["data-theme"] }); |
| 38 | + |
| 39 | + // Abuse the message passing system to force the theme to match at all times |
| 40 | + function handleMessage(event) { |
| 41 | + if (event.origin !== "https://giscus.app") return; |
| 42 | + if (!(typeof event.data === "object" && event.data.giscus)) return; |
| 43 | + |
| 44 | + const giscusData = event.data.giscus; |
| 45 | + |
| 46 | + // Ignore message and use this to force the theme to work for the first message |
| 47 | + updateGiscusTheme(); |
| 48 | + } |
| 49 | + |
| 50 | + // Attach listeners |
| 51 | + document.addEventListener("DOMContentLoaded", updateGiscusTheme); |
| 52 | + |
| 53 | + window.addEventListener("message", handleMessage); |
| 54 | +</script> |
0 commit comments