Skip to content

Commit

Permalink
fix color theme
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Sheep committed Jun 26, 2024
1 parent 6e7849b commit c26ce3e
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions app/components/comment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import { useTheme } from "next-themes";
}

export default function Comment() {
const { systemTheme, theme, setTheme } = useTheme();
const { systemTheme, theme } = useTheme();
const currentTheme = theme === "system" ? systemTheme : theme;
const t = currentTheme === "light" ? "github-light" : "github-dark";

const ref = useRef<HTMLDivElement | null>(null);
useEffect(() => {
if (!currentTheme) return;

const existingScript = document.getElementById("utterances-script");
if (existingScript) return;

Expand All @@ -30,13 +31,10 @@ export default function Comment() {
"repo",
"WildChickenUniversity/WildChickenUniversity"
);
scriptElement.setAttribute(
"theme",
currentTheme === "light" ? "github-light" : "github-dark"
);
scriptElement.setAttribute("theme", t);

ref.current?.appendChild(scriptElement);
}, []);
}, [currentTheme, t]);

return <div ref={ref} />;
}

0 comments on commit c26ce3e

Please sign in to comment.