Skip to content

Commit 74c5c4a

Browse files
authored
Integrate Gitalk as comment plugin for documents and blogs (#83)
* feat(gitalk): added gitalk to store users' comments * fix(gitalk): fixed wrong confugration for gitalk * chore(clientID): replace client id with that of ob organization * chore(CI): added ci workflow for building website
1 parent f070374 commit 74c5c4a

File tree

4 files changed

+1971
-2196
lines changed

4 files changed

+1971
-2196
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Build the website
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build-website:
10+
name: Build the website
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
- uses: actions/setup-node@v4
17+
with:
18+
node-version: 18
19+
cache: yarn
20+
cache-dependency-path: './yarn.lock'
21+
- name: Install dependencies
22+
run: yarn install --frozen-lockfile
23+
- name: Build website
24+
run: yarn build

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
"@mdx-js/react": "^3.0.0",
2121
"bootstrap": "^5.3.3",
2222
"clsx": "^2.0.0",
23+
"gitalk": "^1.8.0",
24+
"js-md5": "^0.8.3",
2325
"prism-react-renderer": "^2.3.0",
2426
"react": "^18.0.0",
2527
"react-bootstrap": "^2.10.2",

src/theme/DocPaginator/index.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import 'gitalk/dist/gitalk.css';
2+
3+
import BrowserOnly from '@docusaurus/BrowserOnly';
4+
import DocPaginator from '@theme-original/DocPaginator';
5+
import type DocPaginatorType from '@theme/DocPaginator';
6+
import GitalkComponent from 'gitalk/dist/gitalk-component';
7+
import React from 'react';
8+
import type { WrapperProps } from '@docusaurus/types';
9+
import {md5} from 'js-md5';
10+
11+
type Props = WrapperProps<typeof DocPaginatorType>;
12+
13+
export default function DocPaginatorWrapper(props: Props): JSX.Element {
14+
return (
15+
<>
16+
<DocPaginator {...props} />
17+
<BrowserOnly fallback={<div>Loading...</div>}>
18+
{() => (
19+
<GitalkComponent
20+
options={{
21+
clientID: 'Ov23lilna50sUJEsRr3R',
22+
clientSecret: '1355fdc76c695064a8d8e4938e984e1a7b31edda',
23+
owner: 'oceanbase',
24+
repo: 'oceanbase.github.io',
25+
admin: ['powerfooI', 'Teingi', 'liboyang0730', 'hnwyllmm'],
26+
id: md5(location.pathname),
27+
}}
28+
/>
29+
)}
30+
</BrowserOnly>
31+
</>
32+
);
33+
}

0 commit comments

Comments
 (0)