Skip to content

Commit

Permalink
add comment component
Browse files Browse the repository at this point in the history
  • Loading branch information
wj-Mcat committed Jun 29, 2024
1 parent 6b5c827 commit 5fe09ac
Show file tree
Hide file tree
Showing 6 changed files with 6,663 additions and 6,514 deletions.
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@docusaurus/preset-classic": "3.4.0",
"@mdx-js/react": "^3.0.0",
"clsx": "^2.0.0",
"commentbox.io": "^2.1.0",
"prism-react-renderer": "^2.3.0",
"react": "^18.0.0",
"react-dom": "^18.0.0"
Expand Down
24 changes: 24 additions & 0 deletions src/components/CommentSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React, {useEffect} from 'react';
import commentBox from 'commentbox.io';
import {useColorMode} from '@docusaurus/theme-common';

export const CommentSection = () => {
// Depending on the theme, we will show a different
// text color in the comments section
const {colorMode} = useColorMode();
const textColor = colorMode === 'dark' ? 'white' : 'black';

useEffect(() => {
const box = commentBox('5654072275238912-proj', {
textColor: textColor,
});
return () => box();
}, [colorMode]);


return (
<div style={{
marginTop: '54px',
}} className="commentbox"/>
);
};
12 changes: 12 additions & 0 deletions src/theme/BlogPostPaginator/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import BlogPostPaginator from '@theme-original/BlogPostPaginator';
import {CommentSection} from "@site/src/components/CommentSection";

export default function BlogPostPaginatorWrapper(props) {
return (
<>
<BlogPostPaginator {...props} />
<CommentSection/>
</>
);
}
17 changes: 17 additions & 0 deletions src/theme/DocPaginator/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import DocPaginator from '@theme-original/DocPaginator';
import type DocPaginatorType from '@theme/DocPaginator';
import type {WrapperProps} from '@docusaurus/types';

import {CommentSection} from "@site/src/components/CommentSection";

type Props = WrapperProps<typeof DocPaginatorType>;

export default function DocPaginatorWrapper(props: Props): JSX.Element {
return (
<>
<DocPaginator {...props} />
<CommentSection/>
</>
);
}
Loading

0 comments on commit 5fe09ac

Please sign in to comment.