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