Skip to content

Commit 5761c33

Browse files
committed
feat: comments, feedback, gh url
1 parent e7249f4 commit 5761c33

File tree

3 files changed

+81
-2
lines changed

3 files changed

+81
-2
lines changed

docs/.meta.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
comments: true

mkdocs.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ repo_name: TimMcCool/scratchattach
99

1010
theme:
1111
name: material
12+
custom_dir: overrides
13+
1214
palette:
1315
# Palette toggle for light mode
1416
- scheme: default
@@ -43,6 +45,7 @@ plugins:
4345
- social
4446
- search
4547
- glightbox
48+
- meta
4649

4750
markdown_extensions:
4851
- admonition
@@ -85,6 +88,25 @@ extra:
8588
social:
8689
# Took this from the goboscript mkdocs yml file
8790
- icon: fontawesome/brands/github
88-
link: https://github.com/scratch-api/docs
91+
link: https://github.com/scratch-api/
8992
- icon: fontawesome/brands/discord
90-
link: https://discord.gg/mgxyyfnfk8
93+
link: https://discord.gg/mgxyyfnfk8
94+
95+
analytics:
96+
provider: google
97+
property: G-XXXXXXXXXX # these are required fields, but unused
98+
99+
feedback:
100+
title: Was this page helpful?
101+
ratings:
102+
- icon: material/emoticon-happy-outline
103+
name: This page was helpful
104+
data: 1
105+
note: >-
106+
Thanks for your feedback!
107+
- icon: material/emoticon-sad-outline
108+
name: This page could be improved
109+
data: 0
110+
note: >-
111+
Thanks for your feedback! Help us improve this page by
112+
using our <a href="https://github.com/scratch-api/scratch-api.github.io/issues/new/?title=[Feedback]+{title}+-+{url}" target="_blank" rel="noopener">feedback form</a>.

overrides/partials/comments.html

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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="scratch-api/scratch-api.github.io"
6+
data-repo-id="R_kgDOPnOq5g"
7+
data-category="Giscus"
8+
data-category-id="DIC_kwDOPnOq5s4CvZsT"
9+
data-mapping="pathname"
10+
data-strict="1"
11+
data-reactions-enabled="1"
12+
data-emit-metadata="0"
13+
data-input-position="top"
14+
data-theme="preferred_color_scheme"
15+
data-lang="en"
16+
data-loading="lazy"
17+
crossorigin="anonymous"
18+
async>
19+
</script>
20+
21+
<!-- Synchronize Giscus theme with palette -->
22+
<script>
23+
var giscus = document.querySelector("script[src*=giscus]")
24+
25+
// Set palette on initial load
26+
var palette = __md_get("__palette")
27+
if (palette && typeof palette.color === "object") {
28+
var theme = palette.color.scheme === "slate"
29+
? "transparent_dark"
30+
: "light"
31+
32+
// Instruct Giscus to set theme
33+
giscus.setAttribute("data-theme", theme)
34+
}
35+
36+
// Register event handlers after documented loaded
37+
document.addEventListener("DOMContentLoaded", function() {
38+
var ref = document.querySelector("[data-md-component=palette]")
39+
ref.addEventListener("change", function() {
40+
var palette = __md_get("__palette")
41+
if (palette && typeof palette.color === "object") {
42+
var theme = palette.color.scheme === "slate"
43+
? "transparent_dark"
44+
: "light"
45+
46+
// Instruct Giscus to change theme
47+
var frame = document.querySelector(".giscus-frame")
48+
frame.contentWindow.postMessage(
49+
{ giscus: { setConfig: { theme } } },
50+
"https://giscus.app"
51+
)
52+
}
53+
})
54+
})
55+
</script>
56+
{% endif %}

0 commit comments

Comments
 (0)