Skip to content

Commit 2c3ada8

Browse files
Add Giscus comments integration for documentation pages
Integrate Giscus (GitHub Discussions-based comments) to enable community discussions on documentation pages. The comment widget respects the site's color mode and appears at the bottom of each doc page. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent d0dd660 commit 2c3ada8

File tree

4 files changed

+117
-0
lines changed

4 files changed

+117
-0
lines changed

package-lock.json

Lines changed: 74 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"dependencies": {
1818
"@docusaurus/core": "3.9.2",
1919
"@docusaurus/preset-classic": "3.9.2",
20+
"@giscus/react": "^3.1.0",
2021
"@mdx-js/react": "^3.0.0",
2122
"clsx": "^2.0.0",
2223
"prism-react-renderer": "^2.3.0",
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from 'react';
2+
import Giscus from '@giscus/react';
3+
import { useColorMode } from '@docusaurus/theme-common';
4+
5+
export default function GiscusComments(): React.ReactElement {
6+
const { colorMode } = useColorMode();
7+
8+
return (
9+
<div style={{ marginTop: '2rem' }}>
10+
<Giscus
11+
repo="winterfx/system-design"
12+
repoId="R_kgDOQ8MNJw"
13+
category="Announcements"
14+
categoryId="DIC_kwDOQ8MNJ84C1I4j"
15+
mapping="pathname"
16+
strict="0"
17+
reactionsEnabled="1"
18+
emitMetadata="0"
19+
inputPosition="bottom"
20+
theme={colorMode === 'dark' ? 'dark' : 'light'}
21+
lang="zh-CN"
22+
loading="lazy"
23+
/>
24+
</div>
25+
);
26+
}

src/theme/DocItem/Footer/index.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from 'react';
2+
import Footer from '@theme-original/DocItem/Footer';
3+
import type FooterType from '@theme/DocItem/Footer';
4+
import type { WrapperProps } from '@docusaurus/types';
5+
import GiscusComments from '@site/src/components/GiscusComments';
6+
7+
type Props = WrapperProps<typeof FooterType>;
8+
9+
export default function FooterWrapper(props: Props): React.ReactElement {
10+
return (
11+
<>
12+
<Footer {...props} />
13+
<GiscusComments />
14+
</>
15+
);
16+
}

0 commit comments

Comments
 (0)