Skip to content

Commit b18b818

Browse files
committed
添加 Giscus 评论系统
1 parent ec16b03 commit b18b818

File tree

3 files changed

+117
-3
lines changed

3 files changed

+117
-3
lines changed

docs/.vitepress/theme/index.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// https://vitepress.dev/guide/custom-theme
22
import { h, onMounted, watch, nextTick } from 'vue'
33
import type { Theme } from 'vitepress'
4-
import { inBrowser, useRoute } from 'vitepress'
4+
import { inBrowser, useData, useRoute } from 'vitepress'
55
import DefaultTheme from 'vitepress/theme'
66
import './style.css'
77
import './style/index.css'
@@ -17,6 +17,7 @@ import HomeUnderline from './components/HomeUnderline.vue'
1717
import TeamCard from './components/TeamCard.vue'
1818
import Download from './components/Download.vue'
1919
import Donate from './components/Donate.vue'
20+
import giscusTalk from 'vitepress-plugin-comment-with-giscus'
2021

2122
export default {
2223
extends: DefaultTheme,
@@ -53,5 +54,26 @@ export default {
5354
() => route.path,
5455
() => nextTick(() => initZoom())
5556
);
57+
// Get frontmatter and route
58+
const { frontmatter } = useData();
59+
60+
// giscus配置
61+
giscusTalk({
62+
repo: 'SECTL/SecRandom-docs', //仓库
63+
repoId: 'R_kgDOPRYlZg', //仓库ID
64+
category: 'General', // 讨论分类
65+
categoryId: 'DIC_kwDOPRYlZs4CvPMD', //讨论分类ID
66+
mapping: 'pathname',
67+
inputPosition: 'bottom',
68+
lang: 'zh-CN',
69+
},
70+
{
71+
frontmatter, route
72+
},
73+
//默认值为true,表示已启用,此参数可以忽略;
74+
//如果为false,则表示未启用
75+
//您可以使用“comment:true”序言在页面上单独启用它
76+
true
77+
);
5678
}
5779
} satisfies Theme

package-lock.json

Lines changed: 92 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"devDependencies": {
3-
"vitepress": "^1.6.3"
3+
"vitepress": "^1.6.3",
4+
"vitepress-plugin-comment-with-giscus": "^1.1.15"
45
},
56
"scripts": {
67
"docs:dev": "vitepress dev docs",

0 commit comments

Comments
 (0)