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