Closed mjy9088 closed 4 months ago
I think I didn't try enough. sorry. I solved it :)
'use client';
import { useContext } from 'react';
import { ModeContext } from '@-ft/mode-next';
import Giscus from '@giscus/react';
export interface CommentProps {
slug: string;
}
export function Comment({ slug }: CommentProps) {
const { theme } = useContext(ModeContext);
return (
<Giscus
// ...
theme={theme}
// ...
/>
);
}
Many websites, including mine, use dark mode when the
html
element has the classdark
.I modified the theme CSS to support this dark mode strategy: giscus-theme.
I confirmed it works when I manually add/remove the
dark
class on thehtml
element in the iframe.It would be super useful if the Giscus component exposed an API for adding/removing the
dark
class on thehtml
element.