vitepress-plugin-comment-with-giscus
Advanced tools
Comparing version 1.1.0 to 1.1.1
import { Ref } from 'vue'; | ||
import { PageData } from 'vitepress'; | ||
import { PageData, Route } from 'vitepress'; | ||
import { GiscusProps } from '@giscus/vue/dist/types'; | ||
declare const giscusTalk: (frontmatter: Ref<PageData['frontmatter']>, props: GiscusProps) => void; | ||
type vitepressAPI = { | ||
frontmatter: Ref<PageData['frontmatter']>; | ||
route: Route; | ||
}; | ||
/** | ||
* 创建评论区 | ||
* @param props giscus配置 | ||
* @param vitepressObj 前言和路由 | ||
*/ | ||
declare const giscusTalk: (props: GiscusProps, vitepressObj: vitepressAPI) => void; | ||
export default giscusTalk; |
import giscus from '@giscus/vue'; | ||
import { createApp, h, nextTick, onMounted, watch } from 'vue'; | ||
import { useRoute } from 'vitepress'; | ||
/** | ||
@@ -74,12 +73,16 @@ * 添加评论容器 | ||
}; | ||
const giscusTalk = (frontmatter, props) => { | ||
const route = useRoute(); | ||
/** | ||
* 创建评论区 | ||
* @param props giscus配置 | ||
* @param vitepressObj 前言和路由 | ||
*/ | ||
const giscusTalk = (props, vitepressObj) => { | ||
onMounted(() => { | ||
setGiscus(props, frontmatter); | ||
setGiscus(props, vitepressObj.frontmatter); | ||
setThemeWatch(); | ||
}); | ||
watch(() => route.path, () => nextTick(() => { | ||
setGiscus(props, frontmatter); | ||
watch(() => vitepressObj.route.path, () => nextTick(() => { | ||
setGiscus(props, vitepressObj.frontmatter); | ||
})); | ||
}; | ||
export default giscusTalk; |
{ | ||
"name": "vitepress-plugin-comment-with-giscus", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "vitepress comment plugin based on giscus", | ||
@@ -5,0 +5,0 @@ "workspaces": [ |
@@ -26,3 +26,3 @@ # README | ||
import giscusTalk from 'vitepress-plugin-comment-with-giscus'; | ||
import { useData } from 'vitepress'; | ||
import { useData, useRoute } from 'vitepress'; | ||
export default { | ||
@@ -35,6 +35,7 @@ ...DefaultTheme, | ||
setup() { | ||
// Get frontmatter | ||
// Get frontmatter and route | ||
const { frontmatter } = useData(); | ||
const route = useRoute(); | ||
// Comment component | ||
giscusTalk(frontmatter, { | ||
giscusTalk({ | ||
repo: 'your github repository', | ||
@@ -44,2 +45,4 @@ repoId: 'your repository id', | ||
mapping: 'pathname' | ||
}, { | ||
frontmatter, route | ||
}); | ||
@@ -46,0 +49,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
9450
196
61