add support for giscus with an unsolved bug, good night :(

This commit is contained in:
Mivinci 2022-11-09 01:19:04 +08:00
parent 3b6079c2a5
commit 43fdd9cb18
3 changed files with 52 additions and 8 deletions

View file

@ -65,11 +65,21 @@ params:
shortname: hugo-minima
# utterances specifies the configuration for Utterances.
# What is Utterances? Check this out: https://utteranc.es
# Check out https://utteranc.es for the following three attributes.
utterances:
repo: "mivinci/hugo-theme-minima"
issueTerm: "pathname"
label: "comment"
repo: mivinci/hugo-theme-minima
issueTerm: pathname
label: comment
# giscus specifies the configuration for Giscus.
# Check out https://giscus.app for the following six attributes.
giscus:
repo: mivinci/hugo-theme-minima
repoId: MDEwOlJlcG9zaXRvcnkzODcxMjM2NDU=
category: Comments
categoryId: DIC_kwDOFxMJvc4CScQm
mapping: pathname
inputPostion: buttom
# **DEPRECATED**
# ovo(https://ovo.js.org) is a comment plugin written by the author of Minima but

View file

@ -35,17 +35,23 @@
{{ end }}
{{ if or .Params.comment (and .Site.Params.commentOnAllPosts (ne .Params.comment false)) }}
{{ if eq .Site.Params.comment "disqus"}}
{{ partial "disqus.html" . }}
{{ end }}
{{ if eq .Site.Params.comment "utterances"}}
{{ partial "utterances.html" . }}
{{ end }}
{{ if eq .Site.Params.comment "giscus" }}
{{ partial "giscus.html" }}
{{ end }}
{{ if eq .Site.Params.comment "ovo"}}
{{ partial "ovo.html" . }}
{{ end }}
{{ if eq .Site.Params.comment "utterances"}}
{{ partial "utterances.html" . }}
{{ end }}
{{ end }}
</div>
{{ end }}

View file

@ -0,0 +1,28 @@
<script>
const repo = '{{ .Site.Params.giscus.repo }}'
const repoId = '{{ .Site.Params.giscus.repoId }}'
const category = '{{ .Site.Params.giscus.category }}'
const categoryId = '{{ .Site.Params.giscus.categoryId }}'
const mapping = '{{ .Site.Params.giscus.mapping }}'
const inputPosition = '{{ .Site.Params.giscus.inputPosition }}'
const theme = localStorage.theme || 'preferred-color-scheme';
const s = document.createElement('script')
s.src = 'https://giscus.app/client.js'
s.async = true
s.crossOrigin = 'anonymous'
s.setAttribute('data-repo', repo)
s.setAttribute('data-repo-id', repoId)
s.setAttribute('data-category', category)
s.setAttribute('data-category-id', categoryId)
s.setAttribute('data-mapping', mapping)
s.setAttribute('data-strict', "0")
s.setAttribute('data-reactions-enabled', "1")
s.setAttribute('data-emit-metadata', "0")
s.setAttribute('data-input-position', inputPosition)
s.setAttribute('data-theme', theme)
s.setAttribute('data-loading', "lazy")
s.setAttribute('data-lang', "en")
document.querySelector('main').appendChild(s)
</script>