Skip to content

Commit 02b578e

Browse files
committed
🎉 feat: add comment component
1 parent 5920c2a commit 02b578e

File tree

3 files changed

+88
-18
lines changed

3 files changed

+88
-18
lines changed

bun.lock

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"view-transitions-api-types": "^0.1.1",
4949
"vite-plugin-node-polyfills": "^0.23.0",
5050
"vitepress": "^1.6.3",
51+
"vitepress-plugin-comment-with-giscus": "^1.1.15",
5152
"vitepress-plugin-llms": "^0.0.16",
5253
"vue": "^3.5.13",
5354
},
@@ -319,6 +320,8 @@
319320

320321
"@floating-ui/utils": ["@floating-ui/[email protected]", "", {}, "sha512-MDWhGtE+eHw5JW7lq4qhc5yRLS11ERl1c7Z6Xd0a58DozHES6EnNNwUWbMiG4J9Cgj053Bhk8zvlhFYKVhULwg=="],
321322

323+
"@giscus/vue": ["@giscus/[email protected]", "", { "dependencies": { "giscus": "^1.4.0" }, "peerDependencies": { "vue": ">=3.2.0" } }, "sha512-QOxKHgsMT91myyQagP2v20YYAei1ByZuc3qcaYxbHx4AwOeyVrybDIuRFwG9YDv6OraC86jYnU4Ixd37ddC/0A=="],
324+
322325
"@graphql-tools/executor": ["@graphql-tools/[email protected]", "", { "dependencies": { "@graphql-tools/utils": "^9.2.1", "@graphql-typed-document-node/core": "3.2.0", "@repeaterjs/repeater": "3.0.4", "tslib": "^2.4.0", "value-or-promise": "1.0.12" }, "peerDependencies": { "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" } }, "sha512-xZC0C+/npXoSHBB5bsJdwxDLgtl1Gu4fL9J2TPQmXoZC3L2N506KJoppf9LgWdHU/xK04luJrhP6WjhfkIN0pQ=="],
323326

324327
"@graphql-tools/merge": ["@graphql-tools/[email protected]", "", { "dependencies": { "@graphql-tools/utils": "^9.2.1", "tslib": "^2.4.0" }, "peerDependencies": { "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" } }, "sha512-XbrHAaj8yDuINph+sAfuq3QCZ/tKblrTLOpirK0+CAgNlZUCHs0Fa+xtMUURgwCVThLle1AF7svJCxFizygLsw=="],
@@ -361,6 +364,10 @@
361364

362365
"@kitajs/ts-html-plugin": ["@kitajs/[email protected]", "", { "dependencies": { "chalk": "^4.1.2", "tslib": "^2.8.1", "yargs": "^17.7.2" }, "peerDependencies": { "@kitajs/html": "^4.2.5", "typescript": "^5.6.2" }, "bin": { "ts-html-plugin": "dist/cli.js", "xss-scan": "dist/cli.js" } }, "sha512-wmjyV8hmJmDOnUM/ZyPkc0UBYgUYmf32/93rkW8wr8h+HiHVMU0tEKFnmRdBjTcy9jwoC9Bnt2NuzS9l67lq5g=="],
363366

367+
"@lit-labs/ssr-dom-shim": ["@lit-labs/[email protected]", "", {}, "sha512-nQIWonJ6eFAvUUrSlwyHDm/aE8PBDu5kRpL0vHMg6K8fK3Diq1xdPjTnsJSwxABhaZ+5eBi1btQB5ShUTKo4nQ=="],
368+
369+
"@lit/reactive-element": ["@lit/[email protected]", "", { "dependencies": { "@lit-labs/ssr-dom-shim": "^1.2.0" } }, "sha512-GFn91inaUa2oHLak8awSIigYz0cU0Payr1rcFsrkf5OJ5eSPxElyZfKh0f2p9FsTiZWXQdWGJeXZICEfXXYSXQ=="],
370+
364371
"@nodelib/fs.scandir": ["@nodelib/[email protected]", "", { "dependencies": { "@nodelib/fs.stat": "2.0.5", "run-parallel": "^1.1.9" } }, "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g=="],
365372

366373
"@nodelib/fs.stat": ["@nodelib/[email protected]", "", {}, "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A=="],
@@ -619,6 +626,8 @@
619626

620627
"@types/shimmer": ["@types/[email protected]", "", {}, "sha512-UE7oxhQLLd9gub6JKIAhDq06T0F6FnztwMNRvYgjeQSBeMc1ZG/tA47EwfduvkuQS8apbkM/lpLpWsaCeYsXVg=="],
621628

629+
"@types/trusted-types": ["@types/[email protected]", "", {}, "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw=="],
630+
622631
"@types/unist": ["@types/[email protected]", "", {}, "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q=="],
623632

624633
"@types/web-bluetooth": ["@types/[email protected]", "", {}, "sha512-g9gZnnXVq7gM7v3tJCWV/qw7w+KeOlSHAhgF9RytFyifW6AF61hdT2ucrYhPq9hLs5JIryeupHV3qGk95dH9ow=="],
@@ -1061,6 +1070,8 @@
10611070

10621071
"get-stream": ["[email protected]", "", { "dependencies": { "@sec-ant/readable-stream": "^0.4.1", "is-stream": "^4.0.1" } }, "sha512-kVCxPF3vQM/N0B1PmoqVUqgHP+EeVjmZSQn+1oCRPxd2P21P2F19lIgbR3HBosbB1PUhOAoctJnfEn2GbN2eZA=="],
10631072

1073+
"giscus": ["[email protected]", "", { "dependencies": { "lit": "^3.2.1" } }, "sha512-Zrsi8r4t1LVW950keaWcsURuZUQwUaMKjvJgTCY125vkW6OiEBkatE7ScJDbpqKHdZwb///7FVC21SE3iFK3PQ=="],
1074+
10641075
"glob": ["[email protected]", "", { "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" } }, "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q=="],
10651076

10661077
"glob-parent": ["[email protected]", "", { "dependencies": { "is-glob": "^4.0.3" } }, "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A=="],
@@ -1237,6 +1248,12 @@
12371248

12381249
"linkify-it": ["[email protected]", "", { "dependencies": { "uc.micro": "^2.0.0" } }, "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ=="],
12391250

1251+
"lit": ["[email protected]", "", { "dependencies": { "@lit/reactive-element": "^2.0.4", "lit-element": "^4.1.0", "lit-html": "^3.2.0" } }, "sha512-1BBa1E/z0O9ye5fZprPtdqnc0BFzxIxTTOO/tQFmyC/hj1O3jL4TfmLBw0WEwjAokdLwpclkvGgDJwTIh0/22w=="],
1252+
1253+
"lit-element": ["[email protected]", "", { "dependencies": { "@lit-labs/ssr-dom-shim": "^1.2.0", "@lit/reactive-element": "^2.0.4", "lit-html": "^3.2.0" } }, "sha512-HO9Tkkh34QkTeUmEdNYhMT8hzLid7YlMlATSi1q4q17HE5d9mrrEHJ/o8O2D0cMi182zK1F3v7x0PWFjrhXFew=="],
1254+
1255+
"lit-html": ["[email protected]", "", { "dependencies": { "@types/trusted-types": "^2.0.2" } }, "sha512-qI/3lziaPMSKsrwlxH/xMgikhQ0EGOX2ICU73Bi/YHFvz2j/yMCIrw4+puF2IpQ4+upd3EWbvnHM9+PnJn48YA=="],
1256+
12401257
"locate-path": ["[email protected]", "", { "dependencies": { "p-locate": "^5.0.0" } }, "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw=="],
12411258

12421259
"lodash": ["[email protected]", "", {}, "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="],
@@ -1843,6 +1860,8 @@
18431860

18441861
"vitepress": ["[email protected]", "", { "dependencies": { "@docsearch/css": "3.8.2", "@docsearch/js": "3.8.2", "@iconify-json/simple-icons": "^1.2.21", "@shikijs/core": "^2.1.0", "@shikijs/transformers": "^2.1.0", "@shikijs/types": "^2.1.0", "@types/markdown-it": "^14.1.2", "@vitejs/plugin-vue": "^5.2.1", "@vue/devtools-api": "^7.7.0", "@vue/shared": "^3.5.13", "@vueuse/core": "^12.4.0", "@vueuse/integrations": "^12.4.0", "focus-trap": "^7.6.4", "mark.js": "8.11.1", "minisearch": "^7.1.1", "shiki": "^2.1.0", "vite": "^5.4.14", "vue": "^3.5.13" }, "peerDependencies": { "markdown-it-mathjax3": "^4", "postcss": "^8" }, "optionalPeers": ["markdown-it-mathjax3", "postcss"], "bin": { "vitepress": "bin/vitepress.js" } }, "sha512-fCkfdOk8yRZT8GD9BFqusW3+GggWYZ/rYncOfmgcDtP3ualNHCAg+Robxp2/6xfH1WwPHtGpPwv7mbA3qomtBw=="],
18451862

1863+
"vitepress-plugin-comment-with-giscus": ["[email protected]", "", { "dependencies": { "@giscus/vue": "^2.2.8" } }, "sha512-1DJjgN+7SYvn5ZkjuSXPmz7nlqfcrh4qCGGviiZghA2ELXnaO2m9WY7m+RisPSaqCn90xqe0JbO2T4NMq8iUBg=="],
1864+
18461865
"vitepress-plugin-llms": ["[email protected]", "", { "dependencies": { "gray-matter": "^4.0.3", "markdown-title": "^1.0.2", "minimatch": "^10.0.1", "picocolors": "^1.1.1", "string-strip-html": "^13.4.12" } }, "sha512-wtA8EhtXELhrwmSxgDuj3nX0iCL99igffFJsj8T1Mb98RsqZl1rYdy5PNFpF3jfjP96xAwT+q9LjfRYvtoLIuA=="],
18471866

18481867
"vm-browserify": ["[email protected]", "", {}, "sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ=="],

docs/.vitepress/theme/index.ts

Lines changed: 68 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
import { useData, useRoute } from 'vitepress'
22
import type { EnhanceAppContext, Theme } from 'vitepress'
33

44
import DefaultTheme from 'vitepress/theme'
@@ -9,30 +9,80 @@ import Layout from './layout.vue'
99
import TwoslashFloatingVue from '@shikijs/vitepress-twoslash/client'
1010
import '@shikijs/vitepress-twoslash/style.css'
1111

12-
import {
13-
NolebaseGitChangelogPlugin
14-
} from '@nolebase/vitepress-plugin-git-changelog/client'
12+
import { NolebaseGitChangelogPlugin } from '@nolebase/vitepress-plugin-git-changelog/client'
1513
import '@nolebase/vitepress-plugin-git-changelog/client/style.css'
1614

17-
import {
18-
NolebaseInlineLinkPreviewPlugin,
19-
} from '@nolebase/vitepress-plugin-inline-link-preview/client'
15+
import { NolebaseInlineLinkPreviewPlugin } from '@nolebase/vitepress-plugin-inline-link-preview/client'
2016
import '@nolebase/vitepress-plugin-inline-link-preview/client/style.css'
2117

22-
import {
23-
NolebaseUnlazyImg,
24-
} from '@nolebase/vitepress-plugin-thumbnail-hash/client'
18+
import { NolebaseUnlazyImg } from '@nolebase/vitepress-plugin-thumbnail-hash/client'
2519
import '@nolebase/vitepress-plugin-thumbnail-hash/client/style.css'
2620

21+
import giscusTalk from 'vitepress-plugin-comment-with-giscus'
22+
2723
import '../../tailwind.css'
24+
import { toRefs } from 'vue'
2825

2926
export default {
30-
extends: DefaultTheme,
31-
Layout,
32-
enhanceApp({ app }: EnhanceAppContext) {
33-
app.use(TwoslashFloatingVue)
34-
app.use(NolebaseGitChangelogPlugin)
35-
app.use(NolebaseInlineLinkPreviewPlugin)
36-
app.component('NolebaseUnlazyImg', NolebaseUnlazyImg)
37-
}
27+
extends: DefaultTheme,
28+
Layout,
29+
enhanceApp({ app }: EnhanceAppContext) {
30+
app.use(TwoslashFloatingVue)
31+
app.use(NolebaseGitChangelogPlugin)
32+
app.use(NolebaseInlineLinkPreviewPlugin)
33+
app.component('NolebaseUnlazyImg', NolebaseUnlazyImg)
34+
},
35+
setup() {
36+
// Get frontmatter and route
37+
const { frontmatter } = toRefs(useData())
38+
const route = useRoute()
39+
40+
// Obtain configuration from: https://giscus.app/
41+
giscusTalk(
42+
{
43+
repo: 'elysiajs/documentation',
44+
repoId: 'R_kgDOIjgsAg',
45+
category: 'General',
46+
categoryId: 'DIC_kwDOIjgsAs4Covzb',
47+
mapping: 'pathname',
48+
strict: '0',
49+
reactionsEnabled: '0',
50+
emitMetadata: '0',
51+
inputPosition: 'top',
52+
lang: 'en',
53+
loading: 'lazy',
54+
crossorigin: 'anonymous',
55+
lightTheme: 'light',
56+
darkTheme: 'transparent_dark'
57+
58+
// repo: 'your github repository',
59+
// repoId: 'your repository id',
60+
// category: 'your category', // default: `General`
61+
// categoryId: 'your category id',
62+
// mapping: 'pathname', // default: `pathname`
63+
// inputPosition: 'top', // default: `top`
64+
// lang: 'en', // default: `zh-CN`
65+
// // i18n setting (Note: This configuration will override the default language set by lang)
66+
// // Configured as an object with key-value pairs inside:
67+
// // [your i18n configuration name]: [corresponds to the language pack name in Giscus]
68+
// locales: {
69+
// 'zh-Hans': 'zh-CN',
70+
// 'en-US': 'en'
71+
// },
72+
// homePageShowComment: false, // Whether to display the comment area on the homepage, the default is false
73+
// lightTheme: 'light', // default: `light`
74+
// darkTheme: 'transparent_dark' // default: `transparent_dark`
75+
// // ...
76+
},
77+
{
78+
frontmatter,
79+
route
80+
},
81+
// Whether to activate the comment area on all pages.
82+
// The default is true, which means enabled, this parameter can be ignored;
83+
// If it is false, it means it is not enabled.
84+
// You can use `comment: true` preface to enable it separately on the page.
85+
true
86+
)
87+
}
3888
} satisfies Theme

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"view-transitions-api-types": "^0.1.1",
5353
"vite-plugin-node-polyfills": "^0.23.0",
5454
"vitepress": "^1.6.3",
55+
"vitepress-plugin-comment-with-giscus": "^1.1.15",
5556
"vitepress-plugin-llms": "^0.0.16",
5657
"vue": "^3.5.13"
5758
},

0 commit comments

Comments
 (0)