|
| 1 | +{% if page.meta.comments %} |
| 2 | +<h2 id="__comments">{{ lang.t("meta.comments") }}</h2> |
| 3 | +<script |
| 4 | + src="https://giscus.app/client.js" |
| 5 | + data-repo="mumu-lhl/t1d-survival-guide" |
| 6 | + data-repo-id="R_kgDORQE96Q" |
| 7 | + data-category="Announcements" |
| 8 | + data-category-id="DIC_kwDORQE96c4C22EB" |
| 9 | + data-mapping="pathname" |
| 10 | + data-strict="0" |
| 11 | + data-reactions-enabled="1" |
| 12 | + data-emit-metadata="0" |
| 13 | + data-input-position="bottom" |
| 14 | + data-theme="preferred_color_scheme" |
| 15 | + data-lang="zh-CN" |
| 16 | + crossorigin="anonymous" |
| 17 | + async |
| 18 | +></script> |
| 19 | + |
| 20 | +<!-- Synchronize Giscus theme with palette --> |
| 21 | +<script> |
| 22 | + var giscus = document.querySelector("script[src*=giscus]"); |
| 23 | + |
| 24 | + // Set palette on initial load |
| 25 | + var palette = __md_get("__palette"); |
| 26 | + if (palette && typeof palette.color === "object") { |
| 27 | + var theme = |
| 28 | + palette.color.scheme === "slate" ? "transparent_dark" : "light"; |
| 29 | + |
| 30 | + // Instruct Giscus to set theme |
| 31 | + giscus.setAttribute("data-theme", theme); |
| 32 | + } |
| 33 | + |
| 34 | + // Register event handlers after documented loaded |
| 35 | + document.addEventListener("DOMContentLoaded", function () { |
| 36 | + var ref = document.querySelector("[data-md-component=palette]"); |
| 37 | + ref.addEventListener("change", function () { |
| 38 | + var palette = __md_get("__palette"); |
| 39 | + if (palette && typeof palette.color === "object") { |
| 40 | + var theme = |
| 41 | + palette.color.scheme === "slate" |
| 42 | + ? "transparent_dark" |
| 43 | + : "light"; |
| 44 | + |
| 45 | + // Instruct Giscus to change theme |
| 46 | + var frame = document.querySelector(".giscus-frame"); |
| 47 | + frame.contentWindow.postMessage( |
| 48 | + { giscus: { setConfig: { theme } } }, |
| 49 | + "https://giscus.app", |
| 50 | + ); |
| 51 | + } |
| 52 | + }); |
| 53 | + }); |
| 54 | +</script> |
| 55 | +{% endif %} |
0 commit comments