Skip to content

Commit

Permalink
feat: add giscus config properties
Browse files Browse the repository at this point in the history
  • Loading branch information
melonbarCode committed Feb 16, 2022
1 parent f2c0f0a commit c912a22
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
18 changes: 12 additions & 6 deletions components/comments/Giscus.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,21 @@ const Giscus = ({ mapping }) => {

const LoadComments = useCallback(() => {
setEnabledLoadComments(false)

const { repo, repositoryId, category, categoryId, reactions, metadata, inputPosition, lang } =
siteMetadata?.comment?.giscusConfig

const script = document.createElement('script')
script.src = 'https://giscus.app/client.js'
script.setAttribute('data-repo', siteMetadata.comment.giscusConfig.repo)
script.setAttribute('data-repo-id', siteMetadata.comment.giscusConfig.repositoryId)
script.setAttribute('data-category', siteMetadata.comment.giscusConfig.category)
script.setAttribute('data-category-id', siteMetadata.comment.giscusConfig.categoryId)
script.setAttribute('data-repo', repo)
script.setAttribute('data-repo-id', repositoryId)
script.setAttribute('data-category', category)
script.setAttribute('data-category-id', categoryId)
script.setAttribute('data-mapping', mapping)
script.setAttribute('data-reactions-enabled', siteMetadata.comment.giscusConfig.reactions)
script.setAttribute('data-emit-metadata', siteMetadata.comment.giscusConfig.metadata)
script.setAttribute('data-reactions-enabled', reactions)
script.setAttribute('data-emit-metadata', metadata)
script.setAttribute('data-input-position', inputPosition)
script.setAttribute('data-lang', lang)
script.setAttribute('data-theme', commentsTheme)
script.setAttribute('crossorigin', 'anonymous')
script.async = true
Expand Down
4 changes: 4 additions & 0 deletions data/siteMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ const siteMetadata = {
// theme example: light, dark, dark_dimmed, dark_high_contrast
// transparent_dark, preferred_color_scheme, custom
theme: 'light',
// Place the comment box above the comments. options: bottom, top
inputPosition: 'bottom',
// Choose the language giscus will be displayed in. options: en, es, zh-CN, zh-TW, ko, ja etc
lang: 'en',
// theme when dark mode
darkTheme: 'transparent_dark',
// If the theme option above is set to 'custom`
Expand Down

0 comments on commit c912a22

Please sign in to comment.