Skip to content

Commit

Permalink
Merge pull request Mitrichius#203 from Junyi-99/main
Browse files Browse the repository at this point in the history
add Giscus support
  • Loading branch information
Mitrichius authored Sep 18, 2023
2 parents e4e2c0b + 8559a8a commit 01c3a53
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
7 changes: 7 additions & 0 deletions exampleSite/hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ utterancesTheme = "" # optional
utterancesIssue = "" # optional
utterancesLabel = "" # optional

# Giscus support
GiscusRepo = "" # mandatory
GiscusRepoId = "" # mandatory
GiscusCategory = "Announcements" # mandatory
GiscusCategoryId = "" # mandatory
GiscusLazyLoad = false # optional

[[params.social]]
id = "docs"
url = "https://gohugo.io/documentation/"
Expand Down
4 changes: 4 additions & 0 deletions layouts/partials/comments.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@
{{ if .Site.Params.graphcommentId }}
{{ partial "graphcomment.html" . }}
{{ end }}

{{ if .Site.Params.GiscusRepo}}
{{ partial "giscus.html" . }}
{{ end}}
24 changes: 24 additions & 0 deletions layouts/partials/giscus.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{ $theme := .Site.Params.GiscusTheme | default "preferred_color_scheme" }}
{{ $mapping := .Site.Params.GiscusDataMapping | default "og:title" }}
{{ $language := .Site.Params.GiscusLang | default "en" }}
{{ $category := .Site.Params.GiscusDiscussionCategory | default "Announcements" }}
{{ $lazyload := .Site.Params.GiscusLazyLoad | default false }}

<script src="https://giscus.app/client.js"
data-repo="{{- .Site.Params.GiscusRepo -}}"
data-repo-id="{{- .Site.Params.GiscusRepoId -}}"
data-category="{{- .Site.Params.GiscusCategory -}}"
data-category-id="{{- .Site.Params.GiscusCategoryId -}}"
data-mapping="{{ $mapping }}"
data-strict="0"
data-reactions-enabled="1"
data-emit-metadata="0"
data-input-position="bottom"
data-theme="{{ $theme }}"
data-lang="{{ $language }}"
crossorigin="anonymous"
{{ if $lazyload }}
data-loading="lazy"
{{ end }}
async>
</script>

0 comments on commit 01c3a53

Please sign in to comment.