Skip to content

Commit 0117b18

Browse files
authored
Merge pull request 0xPolygon#169 from 0xPolygon/km/feedback
Feedback plugin test
2 parents b233183 + 4e9fee3 commit 0117b18

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

docs/cdk/resources/cdk-repo-reference.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
comments: true
3+
---
4+
15

26
| Component | Description |
37
| ----------------------------------------------------------------------------- | -------------------------------------------------------------------- |

overrides/partials/comments.html

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{% if page.meta.comments %}
2+
<h2 id="__comments">{{ lang.t("meta.comments") }}</h2>
3+
<!-- Insert generated snippet here -->
4+
<script src="https://giscus.app/client.js"
5+
data-repo="0xPolygon/polygon-docs"
6+
data-repo-id="R_kgDOKs6Fqg"
7+
data-category="Announcements"
8+
data-category-id="DIC_kwDOKs6Fqs4CcoXX"
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="en"
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 = palette.color.scheme === "slate"
28+
? "transparent_dark"
29+
: "light"
30+
31+
// Instruct Giscus to set theme
32+
giscus.setAttribute("data-theme", theme)
33+
}
34+
35+
// Register event handlers after documented loaded
36+
document.addEventListener("DOMContentLoaded", function() {
37+
var ref = document.querySelector("[data-md-component=palette]")
38+
ref.addEventListener("change", function() {
39+
var palette = __md_get("__palette")
40+
if (palette && typeof palette.color === "object") {
41+
var theme = 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

Comments
 (0)