Skip to content

Commit

Permalink
feat(vitepress): 添加 giscus 评论系统
Browse files Browse the repository at this point in the history
  • Loading branch information
maomao1996 committed Oct 10, 2023
1 parent 61a614f commit 51562b0
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
37 changes: 37 additions & 0 deletions docs/.vitepress/theme/components/MLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
import { useData } from 'vitepress'
import DefaultTheme from 'vitepress/theme'
import { nextTick, provide } from 'vue'
import Giscus from '@giscus/vue'
import { useFormatPath } from '../composables'
import MNavVisitor from './MNavVisitor.vue'
import MDocFooter from './MDocFooter.vue'
import MAsideSponsors from './MAsideSponsors.vue'
const { Layout } = DefaultTheme
const { isDark } = useData()
const formatPath = useFormatPath()
const enableTransitions = () =>
'startViewTransition' in document &&
Expand Down Expand Up @@ -55,6 +59,26 @@ provide('toggle-appearance', async ({ clientX: x, clientY: y }: MouseEvent) => {
<template #nav-bar-title-after>
<MNavVisitor />
</template>
<template #doc-footer-before>
<div class="doc-comments">
<Giscus
id="comments"
repo="maomao1996/mm-notes"
repoId="MDEwOlJlcG9zaXRvcnkxNTc0ODc5Mjg="
category="Announcements"
categoryId="DIC_kwDOCWMTOM4CZ2rf"
mapping="specific"
:term="formatPath"
strict="1"
reactionsEnabled="1"
emitMetadata="0"
inputPosition="top"
:theme="isDark ? 'dark' : 'light'"
lang="zh-CN"
loading="lazy"
/>
</div>
</template>
<template #doc-after>
<MDocFooter />
</template>
Expand All @@ -63,3 +87,16 @@ provide('toggle-appearance', async ({ clientX: x, clientY: y }: MouseEvent) => {
</template>
</Layout>
</template>

<style>
.prev-next.prev-next {
border-top: none;
}
.doc-comments {
margin-top: 24px;
margin-bottom: 48px;
border-top: 1px solid var(--vp-c-divider);
padding-top: 24px;
}
</style>
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"devDependencies": {
"@femm/prettier": "^1.1.0",
"@femm/verify-commit": "^1.0.1",
"@giscus/vue": "^2.3.0",
"@mdit-vue/shared": "^0.12.1",
"@octokit/rest": "^19.0.13",
"@types/fs-extra": "^11.0.1",
Expand Down
54 changes: 54 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 51562b0

Please sign in to comment.