-
Notifications
You must be signed in to change notification settings - Fork 25.7k
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
Add giscus support #3022
Merged
Merged
Add giscus support #3022
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
a7534a6
Add script in same style as utterances
SeanKilleen c9330c7
Add initial script
SeanKilleen b0d5b1e
Add default settings
SeanKilleen 3348c57
Update changelog
SeanKilleen 31b83b9
Add feature to readme
SeanKilleen c6bccbd
Add comments html
SeanKilleen f8844d7
add comment provider include
SeanKilleen 481f36f
update config in docs
SeanKilleen c25025e
Add URL for additional reference
SeanKilleen 2108f6b
docs for giscus comments
SeanKilleen 55d925a
Unrelated bugfix: add missing version separator
SeanKilleen e6a042e
add space
SeanKilleen 2dae4a9
update history doc
SeanKilleen 50874cf
update about doc
SeanKilleen 80c1db4
add to test config yaml
SeanKilleen 5e8f92d
remove unnecessary / incorrect async attribute
SeanKilleen 655abdd
probably should pass the right config paths
SeanKilleen 5a04d58
lowercase the repo name
SeanKilleen 5fe9ae0
Update docs to address '1' and '0' for reactions_enabled
SeanKilleen 807c816
update two additional docs
SeanKilleen 0a7b730
docs wording fix
SeanKilleen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<script> | ||
'use strict'; | ||
|
||
(function () { | ||
var commentContainer = document.querySelector('#giscus-comments'); | ||
|
||
if (!commentContainer) { | ||
return; | ||
} | ||
|
||
var script = document.createElement('script'); | ||
script.setAttribute('src', 'https://giscus.app/client.js'); | ||
script.setAttribute('data-repo', '{{ site.repository | downcase }}'); | ||
script.setAttribute('data-repo-id', '{{ site.comments.giscus.repo_id }}'); | ||
script.setAttribute('data-category', '{{ site.comments.giscus.category_name }}'); | ||
script.setAttribute('data-category-id', '{{ site.comments.giscus.category_id }}'); | ||
script.setAttribute('data-mapping', '{{ site.comments.giscus.discussion_term | default: "pathname" }}'); | ||
script.setAttribute('data-reactions-enabled', '{{ site.comments.giscus.reactions_enabled | default: 1 }}'); // TODO: Convert from boolean | ||
script.setAttribute('data-theme', '{{ site.comments.giscus.theme | default: "light" }}'); | ||
script.setAttribute('crossorigin', 'anonymous'); | ||
|
||
commentContainer.appendChild(script); | ||
})(); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -333,7 +333,7 @@ For example, | |
|
||
### Comments | ||
|
||
[**Disqus**](https://disqus.com/), [**Discourse**](https://www.discourse.org/), [**Facebook**](https://developers.facebook.com/docs/plugins/comments), [**utterances**](https://utteranc.es/), and static-based commenting via [**Staticman**](https://staticman.net/) are built into the theme. First set the comment provider you'd like to use: | ||
[**Disqus**](https://disqus.com/), [**Discourse**](https://www.discourse.org/), [**Facebook**](https://developers.facebook.com/docs/plugins/comments), [**utterances**](https://utteranc.es/), [**giscus**](https://giscus.app/) and static-based commenting via [**Staticman**](https://staticman.net/) are built into the theme. First set the comment provider you'd like to use: | ||
|
||
| Name | Comment Provider | | ||
| ---------------- | ------------------------- | | ||
|
@@ -343,6 +343,7 @@ For example, | |
| **staticman_v2** | Staticman v2 / v3 | | ||
| **staticman** | Staticman v1 (deprecated) | | ||
| **utterances** | utterances | | ||
| **giscus** | giscus | | ||
| **custom** | Other | | ||
|
||
Then add `comments: true` to each document you want comments visible on. | ||
|
@@ -424,6 +425,35 @@ comments: | |
issue_term: "pathname" | ||
``` | ||
|
||
#### giscus comments | ||
|
||
To use giscus you will need to [install the app](https://github.com/apps/giscus) to your GitHub repository. | ||
|
||
The next step is to go to <https://giscus.app> and fill out the desired settings. This will generate a javascript, which will provide you with some of the settings you will need to configure things below. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix captialization to stay consist with rest of theme docs, e.g. JavaScript. Might read better as "This will generate JavaScript" as "a JavaScript" sounds weird to me. |
||
|
||
You'll need to ensure you've added the following to `_config.yml`: | ||
|
||
```yaml | ||
repository: # GitHub username/repo-name e.g. "mmistakes/minimal-mistakes" | ||
``` | ||
|
||
**Note:** Make sure the repo is public, otherwise your readers will not be able to view the issues/comments. The [discussions feature](https://docs.github.com/en/discussions) also needs to be active on your repo. | ||
{: .notice--warning} | ||
|
||
To enable giscus on the front end set `comments.provider` and the other additional options. | ||
|
||
```yaml | ||
comments: | ||
provider: "giscus" | ||
giscus: | ||
repo_id : # Shown during giscus setup at https://giscus.app | ||
category_name : # Full text name of the category | ||
category_id : # Shown during giscus setup at https://giscus.app | ||
discussion_term : # "pathname" (default), "url", "title", "og:title" | ||
reactions_enabled : # true (default), false | ||
theme : # "light" (default), "dark", "dark_dimmed", "transparent_dark", "preferred_color_scheme" | ||
``` | ||
|
||
#### Static-based comments via Staticman | ||
|
||
Transform user comments into `_data` files that live inside of your GitHub repository by enabling Staticman. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ℹ️ FYI, I added this because it was missing according to the other document. Figured I'd fix it here but if you'd like it as a separate PR I'm happy to do so.