diff --git a/src/components/blogCarousel/blogCard.tsx b/src/components/blogCarousel/blogCard.tsx
index cc3fac22..1f8a0932 100644
--- a/src/components/blogCarousel/blogCard.tsx
+++ b/src/components/blogCarousel/blogCard.tsx
@@ -37,8 +37,8 @@ const BlogCard = ({
initial={{ opacity: 0, y: 40, scale: 0.95 }}
animate={{ opacity: 1, y: 0, scale: 1 }}
transition={{ duration: 0.6, ease: "easeOut" }}
- whileHover={{
- y: -8,
+ whileHover={{
+ y: -8,
scale: 1.02,
transition: { duration: 0.4, ease: "easeOut" }
}}
@@ -46,7 +46,7 @@ const BlogCard = ({
onMouseLeave={() => setIsHovered(false)}
className="relative overflow-hidden h-full transition-all duration-300"
>
-
{/* Category Badge */}
{category}
-
+
{/* Card Image */}
-
+
{/* Card Content */}
{title}
{content}
-
+
{/* Card Meta */}
@@ -73,7 +73,7 @@ const BlogCard = ({
5 min read
-
+
{/* Read More Button */}
Read Article →
diff --git a/src/components/discussions/DiscussionCard.tsx b/src/components/discussions/DiscussionCard.tsx
index 1bee236e..27c7298a 100644
--- a/src/components/discussions/DiscussionCard.tsx
+++ b/src/components/discussions/DiscussionCard.tsx
@@ -123,7 +123,7 @@ export default function DiscussionCard({
}}
/>
) : null}
-
diff --git a/src/components/giscus.tsx b/src/components/giscus.tsx
index 60de700a..f26d0ca8 100644
--- a/src/components/giscus.tsx
+++ b/src/components/giscus.tsx
@@ -1,15 +1,92 @@
+// import React, { useEffect, useRef } from "react";
+
+// const GiscusComments: React.FC = () => {
+// const ref = useRef
(null);
+
+// useEffect(() => {
+// if (!ref.current) return;
+// // Prevent duplicate script injection
+// if (ref.current.querySelector("iframe")) return;
+
+// const script = document.createElement("script");
+// script.src = "https://giscus.app/client.js";
+// script.setAttribute("data-repo", "recodehive/Support");
+// script.setAttribute("data-repo-id", "R_kgDOL9urew");
+// script.setAttribute("data-category", "General");
+// script.setAttribute("data-category-id", "DIC_kwDOL9ure84Cqizj");
+// script.setAttribute("data-mapping", "og:title");
+// script.setAttribute("data-strict", "0");
+// script.setAttribute("data-reactions-enabled", "1");
+// script.setAttribute("data-emit-metadata", "0");
+// script.setAttribute("data-input-position", "top");
+// script.setAttribute("data-theme", "preferred_color_scheme");
+// script.setAttribute("data-lang", "en");
+// script.crossOrigin = "anonymous";
+// script.async = true;
+// ref.current.appendChild(script);
+// }, []);
+
+// return ;
+// };
+
+// export default GiscusComments;
+
+// import React, { useEffect, useRef } from "react";
+// import { useColorMode } from "@docusaurus/theme-common"
+
+// const GiscusComments: React.FC = () => {
+// const ref = useRef(null);
+// const { colorMode } = useColorMode();
+// console.log(colorMode)
+// useEffect(() => {
+// if (!ref.current) return;
+// // Prevent duplicate script injection
+// if (ref.current.querySelector("iframe")) return;
+
+// const script = document.createElement("script");
+// script.src = "https://giscus.app/client.js";
+// script.setAttribute("data-repo", "recodehive/Support");
+// script.setAttribute("data-repo-id", "R_kgDOL9urew");
+// script.setAttribute("data-category", "General");
+// script.setAttribute("data-category-id", "DIC_kwDOL9ure84Cqizj");
+// script.setAttribute("data-mapping", "og:title");
+// script.setAttribute("data-strict", "0");
+// script.setAttribute("data-reactions-enabled", "1");
+// script.setAttribute("data-emit-metadata", "0");
+// script.setAttribute("data-input-position", "top");
+
+// // Set the default theme to "light"
+// script.setAttribute("data-theme", colorMode);
+
+// script.setAttribute("data-lang", "en");
+// script.crossOrigin = "anonymous";
+// script.async = true;
+// ref.current.appendChild(script);
+// }, [colorMode]);
+
+// return ;
+// };
+
+// export default GiscusComments;
+
import React, { useEffect, useRef } from "react";
+import { useColorMode } from "@docusaurus/theme-common";
const GiscusComments: React.FC = () => {
const ref = useRef(null);
+ const { colorMode } = useColorMode(); // colorMode is 'light' or 'dark'
+ // 1. This useEffect handles the initial script loading ONCE.
useEffect(() => {
- if (!ref.current) return;
- // Prevent duplicate script injection
- if (ref.current.querySelector("iframe")) return;
+ // Exit if the ref isn't set or if the script is already there
+ if (!ref.current || ref.current.hasChildNodes()) {
+ return;
+ }
const script = document.createElement("script");
script.src = "https://giscus.app/client.js";
+ script.async = true;
+ script.crossOrigin = "anonymous";
script.setAttribute("data-repo", "recodehive/Support");
script.setAttribute("data-repo-id", "R_kgDOL9urew");
script.setAttribute("data-category", "General");
@@ -19,12 +96,30 @@ const GiscusComments: React.FC = () => {
script.setAttribute("data-reactions-enabled", "1");
script.setAttribute("data-emit-metadata", "0");
script.setAttribute("data-input-position", "top");
- script.setAttribute("data-theme", "preferred_color_scheme");
script.setAttribute("data-lang", "en");
- script.crossOrigin = "anonymous";
- script.async = true;
+
+ // Use the initial colorMode from Docusaurus for the initial theme
+ script.setAttribute("data-theme", colorMode);
+
ref.current.appendChild(script);
- }, []);
+ }, []); // <-- Empty dependency array ensures this runs only once on mount.
+
+ // 2. This useEffect watches for changes in colorMode and sends a message to Giscus.
+ useEffect(() => {
+ const iframe = ref.current?.querySelector(
+ "iframe.giscus-frame"
+ );
+
+ if (!iframe) {
+ return;
+ }
+
+ // Send a message to the Giscus iframe to update its theme
+ iframe.contentWindow.postMessage(
+ { giscus: { setConfig: { theme: colorMode } } },
+ "https://giscus.app"
+ );
+ }, [colorMode]); // <-- This runs every time colorMode changes.
return ;
};