Skip to content

Commit 70e78ae

Browse files
authored
Merge pull request #395 from melonbarCode/add-giscus-config
feat: add giscus config properties
2 parents 55862a1 + c912a22 commit 70e78ae

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

components/comments/Giscus.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,21 @@ const Giscus = ({ mapping }) => {
1717

1818
const LoadComments = useCallback(() => {
1919
setEnabledLoadComments(false)
20+
21+
const { repo, repositoryId, category, categoryId, reactions, metadata, inputPosition, lang } =
22+
siteMetadata?.comment?.giscusConfig
23+
2024
const script = document.createElement('script')
2125
script.src = 'https://giscus.app/client.js'
22-
script.setAttribute('data-repo', siteMetadata.comment.giscusConfig.repo)
23-
script.setAttribute('data-repo-id', siteMetadata.comment.giscusConfig.repositoryId)
24-
script.setAttribute('data-category', siteMetadata.comment.giscusConfig.category)
25-
script.setAttribute('data-category-id', siteMetadata.comment.giscusConfig.categoryId)
26+
script.setAttribute('data-repo', repo)
27+
script.setAttribute('data-repo-id', repositoryId)
28+
script.setAttribute('data-category', category)
29+
script.setAttribute('data-category-id', categoryId)
2630
script.setAttribute('data-mapping', mapping)
27-
script.setAttribute('data-reactions-enabled', siteMetadata.comment.giscusConfig.reactions)
28-
script.setAttribute('data-emit-metadata', siteMetadata.comment.giscusConfig.metadata)
31+
script.setAttribute('data-reactions-enabled', reactions)
32+
script.setAttribute('data-emit-metadata', metadata)
33+
script.setAttribute('data-input-position', inputPosition)
34+
script.setAttribute('data-lang', lang)
2935
script.setAttribute('data-theme', commentsTheme)
3036
script.setAttribute('crossorigin', 'anonymous')
3137
script.async = true

data/siteMetadata.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ const siteMetadata = {
5151
// theme example: light, dark, dark_dimmed, dark_high_contrast
5252
// transparent_dark, preferred_color_scheme, custom
5353
theme: 'light',
54+
// Place the comment box above the comments. options: bottom, top
55+
inputPosition: 'bottom',
56+
// Choose the language giscus will be displayed in. options: en, es, zh-CN, zh-TW, ko, ja etc
57+
lang: 'en',
5458
// theme when dark mode
5559
darkTheme: 'transparent_dark',
5660
// If the theme option above is set to 'custom`

0 commit comments

Comments
 (0)