File tree Expand file tree Collapse file tree 3 files changed +24
-21
lines changed Expand file tree Collapse file tree 3 files changed +24
-21
lines changed Original file line number Diff line number Diff line change 1- //import Giscus, { type Theme } from "@giscus/react";
2- //import { GISCUS } from "@config";
3- import { useEffect } from "react" ;
4-
5- // interface CommentsProps {
6- // lightTheme?: Theme;
7- // darkTheme?: Theme;
8- // }
9-
10- export default function Comments ( ) {
11- // const [theme, setTheme] = useState(() => {
12- // const currentTheme = localStorage.getItem("theme");
13- // const browserTheme = window.matchMedia("(prefers-color-scheme: dark)")
14- // .matches
15- // ? "dark"
16- // : "light";
17-
18- // return currentTheme || browserTheme;
19- // });
1+ import { useEffect, useState } from "react";
2+
3+ interface CommentsProps {
4+ lightTheme?: Theme;
5+ darkTheme?: Theme;
6+ }
7+
8+ export default function Comments({
9+ lightTheme = "light",
10+ darkTheme = "dark",
11+ }: CommentsProps) {
12+ const [theme, setTheme] = useState(() => {
13+ const currentTheme = localStorage.getItem("theme");
14+ const browserTheme = window.matchMedia("(prefers-color-scheme: dark)")
15+ .matches
16+ ? "dark"
17+ : "light";
18+
19+ return currentTheme || browserTheme;
20+ });
2021
2122 useEffect(() => {
2223 const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ import Datetime from "@components/Datetime";
77import type { CollectionEntry } from " astro:content" ;
88import { slugifyStr } from " @utils/slugify" ;
99import ShareLinks from " @components/ShareLinks.astro" ;
10- import Comments from " @components/Comments" ;
1110import { SITE } from " @config" ;
1211
1312export interface Props {
@@ -181,8 +180,11 @@ const nextPost =
181180
182181 <!--
183182 https://github.com/giscus/giscus-component
184- https://github.com/satnaing/astro-paper/blob/main/src/content/blog/how-to-integrate-giscus-comments.md -->
183+ https://github.com/satnaing/astro-paper/blob/main/src/content/blog/how-to-integrate-giscus-comments.md
184+ -->
185+ <!--
185186 <Comments client:only="react" />
187+ -->
186188 <!-- <script async src="https://giscus.app/client.js"-->
187189 <!-- data-repo="[ENTER REPO HERE]"-->
188190 <!-- data-repo-id="[ENTER REPO ID HERE]"-->
File renamed without changes.
You can’t perform that action at this time.
0 commit comments