Skip to content

Commit 7a4d3b3

Browse files
✨ 增加评论区功能
1 parent e53bce3 commit 7a4d3b3

File tree

3 files changed

+92
-1
lines changed

3 files changed

+92
-1
lines changed

docs/.vitepress/theme/index.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { Theme } from 'vitepress'
33
import DefaultTheme from 'vitepress/theme'
44
import mediumZoom from 'medium-zoom';
55
import { onMounted, watch, nextTick } from 'vue';
6-
import { useRoute } from 'vitepress';
6+
import { useRoute, useData } from 'vitepress';
77
import 'virtual:group-icons.css'
88
import "./style/index.css"; //引入自定义的样式
99
import { NProgress } from 'nprogress-v2/dist/index.js' // 进度条组件
@@ -12,6 +12,7 @@ import Confetti from './components/Confetti.vue'
1212
import MyLayout from './components/MyLayout.vue';
1313
import Mouse from './components/Mouse.vue';
1414
import MouseFollower from './components/MouseFollower.vue';
15+
import giscusTalk from 'vitepress-plugin-comment-with-giscus'; // 评论插件
1516
// 不蒜子
1617
import { inBrowser } from 'vitepress'
1718
import busuanzi from 'busuanzi.pure.js'
@@ -27,6 +28,24 @@ export default {
2728
extends: DefaultTheme,
2829
setup() {
2930
const route = useRoute();
31+
const { frontmatter } = useData();
32+
giscusTalk({
33+
repo: 'exploitationExplorers/typecript-gymnastics-challenge', //仓库
34+
repoId: 'R_kgDOODkTiw', //仓库ID
35+
category: 'General', // 讨论分类
36+
categoryId: 'DIC_kwDOODkTi84Coiji', //讨论分类ID
37+
mapping: 'pathname',
38+
inputPosition: 'bottom',
39+
lang: 'zh-CN',
40+
},
41+
{
42+
frontmatter, route
43+
},
44+
//默认值为true,表示已启用,此参数可以忽略;
45+
//如果为false,则表示未启用
46+
//您可以使用“comment:true”序言在页面上单独启用它
47+
true
48+
);
3049
const initZoom = () => {
3150
// mediumZoom('[data-zoomable]', { background: 'var(--vp-c-bg)' }); // 默认
3251
mediumZoom('.main img', { background: 'var(--vp-c-bg)' }); // 不显式添加{data-zoomable}的情况下为所有图像启用此功能

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"nprogress-v2": "^1.1.10",
2424
"sass": "^1.86.0",
2525
"vitepress": "^1.6.3",
26+
"vitepress-plugin-comment-with-giscus": "^1.1.15",
2627
"vitepress-plugin-group-icons": "^1.3.8",
2728
"vue": "^3.5.13"
2829
}

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)