|
| 1 | +(function () { |
| 2 | + const giscusConfig = { |
| 3 | + src: "https://giscus.app/client.js", |
| 4 | + "data-repo": "licyk/SDNote", |
| 5 | + "data-repo-id": "R_kgDOL0EOiA", |
| 6 | + "data-category": "Comment", |
| 7 | + "data-category-id": "DIC_kwDOL0EOiM4Ce_qH", |
| 8 | + "data-mapping": "pathname", |
| 9 | + "data-strict": "0", |
| 10 | + "data-reactions-enabled": "1", |
| 11 | + "data-emit-metadata": "0", |
| 12 | + "data-input-position": "bottom", |
| 13 | + "data-theme": "preferred_color_scheme", |
| 14 | + "data-lang": "zh-CN", |
| 15 | + crossorigin: "anonymous", |
| 16 | + async: "", |
| 17 | + }; |
| 18 | + |
| 19 | + function loadGiscus() { |
| 20 | + const content = document.querySelector(".md-content__inner"); |
| 21 | + if (!content || content.querySelector(".giscus-container")) { |
| 22 | + return; |
| 23 | + } |
| 24 | + |
| 25 | + const container = document.createElement("div"); |
| 26 | + container.className = "giscus-container"; |
| 27 | + |
| 28 | + const script = document.createElement("script"); |
| 29 | + for (const [key, value] of Object.entries(giscusConfig)) { |
| 30 | + script.setAttribute(key, value); |
| 31 | + } |
| 32 | + |
| 33 | + container.appendChild(script); |
| 34 | + content.appendChild(container); |
| 35 | + } |
| 36 | + |
| 37 | + if (typeof document$ !== "undefined") { |
| 38 | + document$.subscribe(loadGiscus); |
| 39 | + } else if (document.readyState === "loading") { |
| 40 | + document.addEventListener("DOMContentLoaded", loadGiscus); |
| 41 | + } else { |
| 42 | + loadGiscus(); |
| 43 | + } |
| 44 | +})(); |
0 commit comments