Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Giscus Support #481

Merged
merged 3 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,18 @@ If you wish use [Utterances](https://github.com/utterance/utterances) comments o

Utterances is loaded in the `comments.html` partial by referring to the `utterances.html` partial. Since `single.html` layout loads comments if comments are enabled, you must ensure *both* the `comments` and `utterances` parameters are configured.

#### Giscus Commenting Support

If you wish to use [giscus](https://giscus.app/) comments on your site, you'll need to perform the following:

* Ensure your repository is [public](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/setting-repository-visibility#making-a-repository-public), otherwise visitors will not be able to view the discussion.
* The [giscus app](https://github.com/apps/giscus) is installed, otherwise visitors will not be able to comment and react.
* The Discussions feature is turned on by [enabling it for your repository](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/enabling-or-disabling-github-discussions-for-a-repository).
* Comment out the line for `disqusShortname = ""` in the `/config/_default/config.toml` file.
* Set `comments = true` in the `/config/_default/params.toml` file.
* Configure the giscus parameters in the `/config/_default/params.toml` file.

Giscus is loaded in the `comments.html` partial by referring to the `giscus.html` partial. Since `single.html` layout loads comments if comments are enabled, you must ensure *both* the `comments` and `giscus` parameters are configured.


### Math notation
Expand Down
12 changes: 12 additions & 0 deletions exampleSite/config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@ languageMenuName = "🌐"
# utterancesTheme = "github-light" # Default: github-dark
# utterancesIssueTerm = "pathname" # Default: pathname

# Enable or disable Giscus comments globally. Default to false.
# giscus = true
# giscusRepo = "GHUsername/Repository.Name" # Giscus is enabled when this param is set
# giscusRepoId = "RepositoryID" # Required for Giscus to work
# giscusCategory = "Blog"
# giscusCategoryId = "CategoryID" # Required for Giscus to work
# giscusMapping = "pathname" # Default: pathname
# giscusReactionsEnabled = "1" # Default: 1 = true
# giscusTheme = "dark_protanopia" # Default: dark_dimmed
# giscusLang = "en" # Default: en


# Maximum number of recent posts. (default: 8)
# numberOfRecentPosts = 8

Expand Down
3 changes: 3 additions & 0 deletions layouts/partials/comments.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
{{ if .Site.Params.utterances }}
{{ template "partials/utterances.html" . }}
{{ end }}
{{ if .Site.Params.giscus }}
{{ template "partials/giscus.html" . }}
{{ end }}
<!-- add custom comments markup here -->
</div>
18 changes: 18 additions & 0 deletions layouts/partials/giscus.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{ if .Site.Params.giscus }}
<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="{{.Site.Params.giscusMapping | default "pathname"}}"
data-strict="0"
data-reactions-enabled="{{.Site.Params.giscusReactionsEnabled | default "1"}}"
data-emit-metadata="0"
data-input-position="top"
data-theme="{{.Site.Params.giscusTheme | default "dark-dimmed"}}"
data-lang="{{.Site.Params.giscusLang | default "en"}}"
data-loading="lazy"
crossorigin="anonymous"
async>
</script>
{{ end }}