File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed
Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -9,13 +9,13 @@ <h2 id="__comments">{{ lang.t("meta.comments") }}</h2>
99 data-mapping ="pathname "
1010 data-strict ="1 "
1111 data-reactions-enabled ="1 "
12- data-emit-metadata ="0 "
12+ data-emit-metadata ="1 "
1313 data-input-position ="bottom "
1414 data-theme ="preferred_color_scheme "
1515 data-lang ="en "
1616 crossorigin ="anonymous "
1717 async >
18- </ script >
18+ </ script >
1919
2020 <!-- Synchronize Giscus theme with palette -->
2121 < script >
@@ -51,5 +51,22 @@ <h2 id="__comments">{{ lang.t("meta.comments") }}</h2>
5151 }
5252 } )
5353 } )
54+ </ script >
55+
56+ < script >
57+ import { MessageEvent , IMetadataMessage } from "https://giscus.app/lib/types/giscus.js" ;
58+
59+ // handle message events
60+ function handleMessage ( event : MessageEvent ) {
61+ if ( event . origin !== 'https://giscus.app' ) return ;
62+ if ( ! ( typeof event . data === 'object' && event . data . giscus ) ) return ;
63+
64+ if ( 'discussion' in giscusData ) {
65+ const metadataMessage : IMetadataMessage = giscusData ;
66+ console . log ( metadataMessage . discussion ) ;
67+ console . log ( metadataMessage . viewer ) ;
68+ }
69+ }
5470 </ script >
55- {% endif %}
71+
72+ {% endif %}
You can’t perform that action at this time.
0 commit comments