chore: organize giscus-related configurations

This commit is contained in:
radishzzz 2025-05-30 12:59:00 +01:00
parent 4b270755bf
commit d12e235a23
8 changed files with 43 additions and 251 deletions

View file

@ -1,6 +1,6 @@
---
// import Disqus from '@/components/Comments/Disqus.astro'
import Giscus from '@/components/Comments/Giscus.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'
@ -9,22 +9,22 @@ const enableComments = themeConfig.comment?.enabled ?? false
// Disqus
// const disqusShortname = themeConfig.comment?.disqus?.shortname || ''
// const showDisqus = enableComments && themeConfig.comment.provider == 'disqus' && disqusShortname.trim() !== ''
// const showDisqus = enableComments && disqusShortname.trim() !== ''
Giscus
const giscusRepo = themeConfig.comment?.giscus?.repo || ''
const showGiscus = enableComments && themeConfig.comment.provider == 'giscus' && giscusRepo.trim() !== ''
// Giscus
// const giscusRepo = themeConfig.comment?.giscus?.repo || ''
// const showGiscus = enableComments && giscusRepo.trim() !== ''
// Twikoo
// const twikooEnvId = themeConfig.comment?.twikoo?.envId || ''
// const showTwikoo = enableComments && themeConfig.comment.provider == 'twikoo' && twikooEnvId.trim() !== ''
// const showTwikoo = enableComments && twikooEnvId.trim() !== ''
// Waline
const walineURL = themeConfig.comment?.waline?.serverURL || ''
const showWaline = enableComments && themeConfig.comment.provider == 'waline' && walineURL.trim() !== ''
const showWaline = enableComments && walineURL.trim() !== ''
---
<!-- {showDisqus && <Disqus />} -->
{showGiscus && <Giscus />}
<!-- {showGiscus && <Giscus />} -->
<!-- {showTwikoo && <Twikoo />} -->
{showWaline && <Waline />}

View file

@ -71,8 +71,7 @@ export const themeConfig: ThemeConfig = {
comment: {
// enable comment system
enabled: true, // true, false
provider: 'waline', // giscus, waline
// waline comment system
// waline
// https://waline.js.org/en/
waline: {
// server url
@ -87,7 +86,20 @@ export const themeConfig: ThemeConfig = {
search: false, // true, false
// image uploader
imageUploader: false, // true, false
}
},
// giscus
// https://giscus.app/
giscus: {
repo: 'radishzzz/comment-giscus',
repoID: 'R_kgDOOy1K0w',
category: 'Announcements',
categoryID: 'DIC_kwDOOy1K084CqwuZ',
mapping: 'pathname',
strict: '0',
reactionsEnabled: '1',
emitMetadata: '0',
inputPosition: 'bottom',
},
},
// COMMENT SETTINGS >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> END

View file

@ -29,13 +29,20 @@ export const walineLocaleMap: Record<string, string> = {
'zh-tw': 'zh-TW',
}
// Giscus Language Map
// https://giscus.app/
export const giscusLocaleMap: Record<string, string> = {
'zh': 'zh-CN',
'zh-tw': 'zh-TW',
'ja': 'ja',
'de': 'de',
'en': 'en',
'es': 'es',
'fr': 'fr',
'ja': 'jp',
'ko': 'ko',
'pl': 'pl',
'pt': 'pt',
'ru': 'ru',
'zh': 'zh-CN',
'zh-tw': 'zh-TW',
}
// Supported Languages

19
src/types/index.d.ts vendored
View file

@ -40,21 +40,22 @@ export interface ThemeConfig {
comment: {
enabled: boolean
provider?: 'waline' | 'giscus'
waline?: {
serverURL?: string
emoji?: string[]
search?: boolean
imageUploader?: boolean
},
}
giscus?: {
repo: string
repoID: string
category: string
categoryID: string
mapping: 'pathname' | 'url' | 'title'
inputPosition: 'top' | 'bottom'
loading: 'lazy' | 'embed'
repo?: string
repoID?: string
category?: string
categoryID?: string
mapping?: 'pathname' | 'url' | 'title' | 'og:title'
strict?: '0' | '1'
reactionsEnabled?: '0' | '1'
emitMetadata?: '0' | '1'
inputPosition?: 'top' | 'bottom'
}
}