Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/components/giscus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ const GiscusComments: React.FC = () => {
return;
}

// Use localStorage to get user's last theme or fallback to 'light'
const storedTheme =
localStorage.getItem("theme") || (
document.documentElement.getAttribute("data-theme") === "dark"
? "dark"
: "light"
);

const script = document.createElement("script");
script.src = "https://giscus.app/client.js";
script.async = true;
Expand All @@ -99,7 +107,7 @@ const GiscusComments: React.FC = () => {
script.setAttribute("data-lang", "en");

// Use the initial colorMode from Docusaurus for the initial theme
script.setAttribute("data-theme", colorMode);
script.setAttribute("data-theme", storedTheme);

ref.current.appendChild(script);
}, []); // <-- Empty dependency array ensures this runs only once on mount.
Expand Down
Loading