feat: add comment system

This commit is contained in:
radishzzz 2025-03-06 23:06:38 +00:00
parent c2ebc78045
commit eabd33f339
6 changed files with 50 additions and 11 deletions

View file

@ -65,9 +65,11 @@
"attributify", "attributify",
"blurhash", "blurhash",
"bmoji", "bmoji",
"Disqus",
"Etiquetas", "Etiquetas",
"Frontmatter", "Frontmatter",
"Fuwriu", "Fuwriu",
"Giscus",
"GSAP", "GSAP",
"gtag", "gtag",
"hètí", "hètí",
@ -92,6 +94,7 @@
"srcset", "srcset",
"STIX", "STIX",
"titlebar", "titlebar",
"Twikoo",
"Umami", "Umami",
"unocss", "unocss",
"unpic", "unpic",

View file

@ -35,7 +35,7 @@ function initWaline() {
el: '#waline', el: '#waline',
path: window.location.pathname.replace(/^\/([a-z]{2}(-[a-z]{2})?)\//, '/'), path: window.location.pathname.replace(/^\/([a-z]{2}(-[a-z]{2})?)\//, '/'),
dark: 'auto', dark: 'auto',
requiredMeta: ['nick'], requiredMeta: ['nick', 'mail'],
highlighter: false, highlighter: false,
texRenderer: false, texRenderer: false,
reaction: [], reaction: [],

View file

@ -0,0 +1,27 @@
---
// import Disqus from '@/components/Comments/Disqus.astro'
// import Giscus from '@/components/Comments/Giscus.astro'
// import Twikoo from '@/components/Comments/Twikoo.astro'
import Waline from '@/components/Comments/Waline.astro'
import { themeConfig } from '@/config'
// Disqus
// const disqusShortname = themeConfig.comment?.disqus?.shortname || ''
// const showDisqus = disqusShortname.trim() !== ''
// Giscus
// const giscusRepo = themeConfig.comment?.giscus?.repo || ''
// const showGiscus = giscusRepo.trim() !== ''
// Twikoo
// const twikooEnvId = themeConfig.comment?.twikoo?.envId || ''
// const showTwikoo = twikooEnvId.trim() !== ''
// Waline
const walineURL = themeConfig.comment?.waline?.serverURL || ''
const showWaline = walineURL.trim() !== ''
---
<!-- {showDisqus && <Disqus />} -->
<!-- {showGiscus && <Giscus />} -->
<!-- {showTwikoo && <Twikoo />} -->
{showWaline && <Waline />}

View file

@ -32,24 +32,33 @@ export const themeConfig: ThemeConfig = {
// GLOBAL SETTINGS >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> START // GLOBAL SETTINGS >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> START
global: { global: {
locale: 'zh', // support 'zh', 'zh-tw', 'ja', 'en', 'es', 'ru'. Default language setting // Default language
moreLocale: ['zh-tw', 'ja', 'en', 'es', 'ru'], // ['zh', 'zh-tw', 'ja', 'en', 'es', 'ru']. Not fill in the default locale code again locale: 'zh', // support 'zh', 'zh-tw', 'ja', 'en', 'es', 'ru'
fontStyle: 'sans', // sans, serif. Font styles for post content // Not fill in the default locale code again
titleSpace: 3, // 1, 2, 3. Space between title and subtitle moreLocale: ['zh-tw', 'ja', 'en', 'es', 'ru'], // ['zh', 'zh-tw', 'ja', 'en', 'es', 'ru']
// Font styles for post content
fontStyle: 'sans', // sans, serif
// Space between title and subtitle
titleSpace: 3, // 1, 2, 3
}, },
// GLOBAL SETTINGS >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> END // GLOBAL SETTINGS >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> END
// COMMENT SETTINGS >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> START // COMMENT SETTINGS >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> START
comment: { comment: {
waline: { waline: {
serverURL: 'https://comment.radishzz.cc', // Waline server URL // Waline server URL
serverURL: 'https://comment.radishzz.cc', // https://comment.example.com
// Emoji
emoji: [ emoji: [
'https://unpkg.com/@waline/emojis@1.2.0/tw-emoji', 'https://unpkg.com/@waline/emojis@1.2.0/tw-emoji',
// 'https://unpkg.com/@waline/emojis@1.2.0/bmoji', // 'https://unpkg.com/@waline/emojis@1.2.0/bmoji',
// see more at https://waline.js.org/en/guide/features/emoji.html // see more at https://waline.js.org/en/guide/features/emoji.html
], ],
search: false, // whether to enable GIF search // Whether to enable GIF search
imageUploader: false, // whether to enable image uploader. BUG search: false, // true, false
// Whether to enable image uploader
// BUGunable to disable image uploader
imageUploader: false, // true, false
}, },
}, },
// COMMENT SETTINGS >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> END // COMMENT SETTINGS >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> END

View file

@ -1,5 +1,5 @@
--- ---
import Waline from '@/components/Comments/Waline.astro' import Comments from '@/components/Comments/index.astro'
import Layout from '@/layouts/Layout.astro' import Layout from '@/layouts/Layout.astro'
import { checkSlugDuplication } from '@/utils/content' import { checkSlugDuplication } from '@/utils/content'
import { generatePostPaths } from '@/utils/i18n' import { generatePostPaths } from '@/utils/i18n'
@ -66,5 +66,5 @@ const { Content, remarkPluginFrontmatter } = await post.render()
)} )}
</article> </article>
<Waline /> <Comments />
</Layout> </Layout>

View file

@ -9,7 +9,7 @@ export const langMap: Record<string, string[]> = {
} }
// Waline Language Map // Waline Language Map
// see more at https://waline.js.org/guide/i18n.html // See more at https://waline.js.org/guide/i18n.html
export const walineLocaleMap: Record<string, string> = { export const walineLocaleMap: Record<string, string> = {
'zh': 'zh-CN', 'zh': 'zh-CN',
'zh-tw': 'zh-TW', 'zh-tw': 'zh-TW',