EN | 中文文档
vitepress
comment section plugin based on giscus
Install
// npm
npm i vitepress-plugin-comment-with-giscus
// yarn
yarn add vitepress-plugin-comment-with-giscus
Usage
In the index
file under the .vitepress/theme
path
import DefaultTheme from 'vitepress/theme';
import giscusTalk from 'vitepress-plugin-comment-with-giscus';
import { useData, useRoute } from 'vitepress';
import { toRefs } from "vue";
export default {
...DefaultTheme,
enhanceApp(ctx) {
DefaultTheme.enhanceApp(ctx);
},
setup() {
const { frontmatter } = toRefs(useData());
const route = useRoute();
giscusTalk({
repo: 'your github repository',
repoId: 'your repository id',
category: 'your category',
categoryId: 'your category id',
mapping: 'pathname',
inputPosition: 'top',
lang: 'en',
locales: {
'zh-Hans': 'zh-CN',
'en-US': 'en'
},
homePageShowComment: false,
lightTheme: 'light',
darkTheme: 'transparent_dark',
}, {
frontmatter, route
},
true
);
}
};
For the parameter acquisition method of giscus
, please refer to:giscus configuration
Click to see the list of currently supported languages
Extended
When the configuration option enables the comment area by default, add the following code, the comment area will not be generated
---
comment: false
---
When the configuration options do not enable the comment area by default, you can still enable the comment area on the current page through the following code
---
comment: true
---
change log
change log
more vitepress plugins
You may be interested in these plugins:
Click me to view more vitepress plugins