From 98bab32f05bb7925130e695484f467ec7b82d26c Mon Sep 17 00:00:00 2001
From: maomao <1714487678@qq.com>
Date: Tue, 9 Apr 2024 21:10:24 +0800
Subject: [PATCH] =?UTF-8?q?feat(vitepress):=20=E6=B7=BB=E5=8A=A0=20giscus?=
=?UTF-8?q?=20=E8=AF=84=E8=AE=BA=20(#8)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docs/.vitepress/config.ts | 7 +++
docs/.vitepress/theme/components/MLayout.vue | 40 ++++++++++++++-
env.d.ts | 15 ++++++
package.json | 1 +
pnpm-lock.yaml | 54 ++++++++++++++++++++
5 files changed, 116 insertions(+), 1 deletion(-)
diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts
index a59bd4ed..685d8b19 100644
--- a/docs/.vitepress/config.ts
+++ b/docs/.vitepress/config.ts
@@ -56,6 +56,13 @@ export default defineConfig({
visitor: {
badgeId: 'maomao1996.vitepress-nav-template',
},
+
+ comment: {
+ repo: 'maomao1996/vitepress-nav-template',
+ repoId: 'R_kgDOJC09Jg',
+ category: 'Announcements',
+ categoryId: 'DIC_kwDOJC09Js4Cekn0',
+ },
},
vite: {
diff --git a/docs/.vitepress/theme/components/MLayout.vue b/docs/.vitepress/theme/components/MLayout.vue
index 448032f4..2db0bb46 100644
--- a/docs/.vitepress/theme/components/MLayout.vue
+++ b/docs/.vitepress/theme/components/MLayout.vue
@@ -2,12 +2,18 @@
import { useData } from 'vitepress'
import DefaultTheme from 'vitepress/theme'
import { nextTick, provide } from 'vue'
+import Giscus from '@giscus/vue'
+
+import { usePageId } from '../composables'
import MNavVisitor from './MNavVisitor.vue'
import MDocFooter from './MDocFooter.vue'
const { Layout } = DefaultTheme
-const { isDark } = useData()
+const { isDark, theme, frontmatter } = useData()
+const pageId = usePageId()
+
+const { comment } = theme.value
const enableTransitions = () =>
'startViewTransition' in document &&
@@ -54,8 +60,40 @@ provide('toggle-appearance', async ({ clientX: x, clientY: y }: MouseEvent) => {
+
+
+
+
+
+
+
diff --git a/env.d.ts b/env.d.ts
index 752de554..97326e44 100644
--- a/env.d.ts
+++ b/env.d.ts
@@ -12,6 +12,21 @@ declare module 'vitepress' {
/** 统计 id(单独页面的统计会作为前缀使用)*/
badgeId: string
}
+
+ /**
+ * giscus 评论配置
+ * 请根据 https://giscus.app/zh-CN 生成内容填写
+ */
+ comment?: {
+ /** github 仓库地址 */
+ repo: `${string}/${string}`
+ /** giscus 仓库 ID */
+ repoId: string
+ /** Discussion 分类 */
+ category: string
+ /** giscus 分类 ID */
+ categoryId: string
+ }
}
}
}
diff --git a/package.json b/package.json
index 2eafc07d..1ee9b1a6 100644
--- a/package.json
+++ b/package.json
@@ -25,6 +25,7 @@
"@femm/prettier": "^1.1.0",
"@femm/tailwind-config": "^1.0.0",
"@femm/verify-commit": "^1.0.1",
+ "@giscus/vue": "^3.0.0",
"@mdit-vue/shared": "^0.12.1",
"@types/node": "^18.18.6",
"autoprefixer": "^10.4.17",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 3360b544..708cab59 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -19,6 +19,9 @@ devDependencies:
'@femm/verify-commit':
specifier: ^1.0.1
version: 1.0.1
+ '@giscus/vue':
+ specifier: ^3.0.0
+ version: 3.0.0(vue@3.4.21)
'@mdit-vue/shared':
specifier: ^0.12.1
version: 0.12.1
@@ -500,6 +503,15 @@ packages:
terminal-link: 3.0.0
dev: true
+ /@giscus/vue@3.0.0(vue@3.4.21):
+ resolution: {integrity: sha512-ZoSUmlc3ee2a+kdumCaXFDZaB4h9b1BYWzsmmRP7zoGEQKYopdAnzGvJK7RdvrYGAzNqZtGUxI0NnBl8/UA6bQ==}
+ peerDependencies:
+ vue: '>=3.2.0'
+ dependencies:
+ giscus: 1.5.0
+ vue: 3.4.21
+ dev: true
+
/@isaacs/cliui@8.0.2:
resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==}
engines: {node: '>=12'}
@@ -542,6 +554,16 @@ packages:
'@jridgewell/sourcemap-codec': 1.4.15
dev: true
+ /@lit-labs/ssr-dom-shim@1.2.0:
+ resolution: {integrity: sha512-yWJKmpGE6lUURKAaIltoPIE/wrbY3TEkqQt+X0m+7fQNnAv0keydnYvbiJFP1PnMhizmIWRWOG5KLhYyc/xl+g==}
+ dev: true
+
+ /@lit/reactive-element@2.0.4:
+ resolution: {integrity: sha512-GFn91inaUa2oHLak8awSIigYz0cU0Payr1rcFsrkf5OJ5eSPxElyZfKh0f2p9FsTiZWXQdWGJeXZICEfXXYSXQ==}
+ dependencies:
+ '@lit-labs/ssr-dom-shim': 1.2.0
+ dev: true
+
/@mdit-vue/shared@0.12.1:
resolution: {integrity: sha512-bXgd0KThe4jC2leCFDFsyrudXIckvTwV4WnQK/rRMrXq0/BAuVdSNdIv1LGCWZxD5+oDyPyEPd0lalTIFwqsmg==}
dependencies:
@@ -747,6 +769,10 @@ packages:
resolution: {integrity: sha512-wf3Vz+jCmOQ2HV1YUJuCWdL64adYxumkrxtc+H1VUQlnQI04+5HtH+qZCOE21lBE7gIrt+CwX2Wv8Acrw5Ak6w==}
dev: true
+ /@types/trusted-types@2.0.7:
+ resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==}
+ dev: true
+
/@types/unist@2.0.10:
resolution: {integrity: sha512-IfYcSBWE3hLpBg8+X2SEa8LVkJdJEkT2Ese2aaLs3ptGdVtABxndrMaxuFlQ1qdFf9Q5rDvDpxI3WwgvKFAsQA==}
dev: true
@@ -1349,6 +1375,12 @@ packages:
engines: {node: '>=10'}
dev: true
+ /giscus@1.5.0:
+ resolution: {integrity: sha512-t3LL0qbSO3JXq3uyQeKpF5CegstGfKX/0gI6eDe1cmnI7D56R7j52yLdzw4pdKrg3VnufwCgCM3FDz7G1Qr6lg==}
+ dependencies:
+ lit: 3.1.2
+ dev: true
+
/glob-parent@5.1.2:
resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==}
engines: {node: '>= 6'}
@@ -1531,6 +1563,28 @@ packages:
wrap-ansi: 8.1.0
dev: true
+ /lit-element@4.0.4:
+ resolution: {integrity: sha512-98CvgulX6eCPs6TyAIQoJZBCQPo80rgXR+dVBs61cstJXqtI+USQZAbA4gFHh6L/mxBx9MrgPLHLsUgDUHAcCQ==}
+ dependencies:
+ '@lit-labs/ssr-dom-shim': 1.2.0
+ '@lit/reactive-element': 2.0.4
+ lit-html: 3.1.2
+ dev: true
+
+ /lit-html@3.1.2:
+ resolution: {integrity: sha512-3OBZSUrPnAHoKJ9AMjRL/m01YJxQMf+TMHanNtTHG68ubjnZxK0RFl102DPzsw4mWnHibfZIBJm3LWCZ/LmMvg==}
+ dependencies:
+ '@types/trusted-types': 2.0.7
+ dev: true
+
+ /lit@3.1.2:
+ resolution: {integrity: sha512-VZx5iAyMtX7CV4K8iTLdCkMaYZ7ipjJZ0JcSdJ0zIdGxxyurjIn7yuuSxNBD7QmjvcNJwr0JS4cAdAtsy7gZ6w==}
+ dependencies:
+ '@lit/reactive-element': 2.0.4
+ lit-element: 4.0.4
+ lit-html: 3.1.2
+ dev: true
+
/log-update@5.0.1:
resolution: {integrity: sha512-5UtUDQ/6edw4ofyljDNcOVJQ4c7OjDro4h3y8e1GQL5iYElYclVHJ3zeWchylvMaKnDbDilC8irOVyexnA/Slw==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}