1
+ <!-- Insert generated snippet here -->
2
+ < script src ="https://giscus.app/client.js "
3
+ data-repo ="PKUFlyingPig/cs-self-learning "
4
+ data-repo-id ="R_kgDOGP67ng "
5
+ data-category ="Announcements "
6
+ data-category-id ="DIC_kwDOGP67ns4COM9Q "
7
+ data-mapping ="title "
8
+ data-reactions-enabled ="1 "
9
+ data-emit-metadata ="0 "
10
+ data-input-position ="top "
11
+ data-theme ="light_protanopia "
12
+ data-lang ="zh-CN "
13
+ data-loading ="lazy "
14
+ crossorigin ="anonymous "
15
+ async >
16
+ </ script >
17
+
18
+ <!-- Synchronize Giscus theme with palette -->
19
+ < script >
20
+ var giscus = document . querySelector ( "script[src*=giscus]" )
21
+
22
+ // Set palette on initial load
23
+ var palette = __md_get ( "__palette" )
24
+ if ( palette && typeof palette . color === "object" ) {
25
+ var theme = palette . color . scheme === "slate"
26
+ ? "dark_protanopia"
27
+ : "light_protanopia"
28
+
29
+ // Instruct Giscus to set theme
30
+ giscus . setAttribute ( "data-theme" , theme )
31
+ }
32
+
33
+ // Register event handlers after documented loaded
34
+ document . addEventListener ( "DOMContentLoaded" , function ( ) {
35
+ var ref = document . querySelector ( "[data-md-component=palette]" )
36
+ ref . addEventListener ( "change" , function ( ) {
37
+ var palette = __md_get ( "__palette" )
38
+ if ( palette && typeof palette . color === "object" ) {
39
+ var theme = palette . color . scheme === "slate"
40
+ ? "dark_protanopia"
41
+ : "light_protanopia"
42
+
43
+ // Instruct Giscus to change theme
44
+ var frame = document . querySelector ( ".giscus-frame" )
45
+ frame . contentWindow . postMessage (
46
+ { giscus : { setConfig : { theme } } } ,
47
+ "https://giscus.app"
48
+ )
49
+ }
50
+ } )
51
+ } )
52
+ </ script >
0 commit comments