@@ -16,6 +16,7 @@ const socialImageURL = new URL(ogImage ? ogImage : "/social-card.png", Astro.url
16
16
---
17
17
18
18
<meta charset =" utf-8" />
19
+ <meta name =" viewport" content =" width=device-width" />
19
20
<meta name =" viewport" content =" width=device-width, initial-scale=1.0, shrink-to-fit=no" />
20
21
<meta http-equiv =" X-UA-Compatible" content =" IE=edge" />
21
22
<title >{ siteTitle } </title >
@@ -74,3 +75,56 @@ const socialImageURL = new URL(ogImage ? ogImage : "/social-card.png", Astro.url
74
75
href =
" https://fonts.googleapis.com/css2?family=Inter:[email protected] &display=swap"
75
76
rel =" stylesheet"
76
77
/>
78
+
79
+ <!-- Giscus -->
80
+ <script >
81
+ document.addEventListener("DOMContentLoaded", function () {
82
+ function getGiscusTheme() {
83
+ const bodyThemeIsDark = document.documentElement.classList.contains("dark");
84
+ return bodyThemeIsDark ? "dark" : "light";
85
+ }
86
+
87
+ function setGiscusTheme() {
88
+ function sendMessage(message) {
89
+ const iframe = document.querySelector("iframe.giscus-frame");
90
+ if (!iframe) return;
91
+ iframe.contentWindow.postMessage({ giscus: message }, "https://giscus.app");
92
+ }
93
+ sendMessage({
94
+ setConfig: {
95
+ theme: getGiscusTheme(),
96
+ },
97
+ });
98
+ }
99
+
100
+ const giscusAttributes = {
101
+ src: "https://giscus.app/client.js",
102
+ "data-repo": "oxwazz/oxwazz.github.io",
103
+ "data-repo-id": "R_kgDOKOXRsQ",
104
+ "data-category": "Announcements",
105
+ "data-category-id": "DIC_kwDOKOXRsc4CeZDU",
106
+ "data-mapping": "pathname",
107
+ "data-strict": "0",
108
+ "data-reactions-enabled": "1",
109
+ "data-emit-metadata": "0",
110
+ "data-input-position": "top",
111
+ "data-theme": getGiscusTheme(),
112
+ "data-lang": "en",
113
+ crossorigin: "anonymous",
114
+ async: "",
115
+ };
116
+
117
+ // Dynamically create script tag
118
+ const giscusScript = document.createElement("script");
119
+ Object.entries(giscusAttributes).forEach(([key, value]) =>
120
+ giscusScript.setAttribute(key, value),
121
+ );
122
+ document.querySelector("head").appendChild(giscusScript);
123
+
124
+ // Update giscus theme when theme switcher is clicked
125
+ const toggle = document.querySelector("theme-toggle");
126
+ if (toggle) {
127
+ toggle.addEventListener("click", setGiscusTheme);
128
+ }
129
+ });
130
+ </script >
0 commit comments