Skip to content

Commit

Permalink
Add giscus
Browse files Browse the repository at this point in the history
  • Loading branch information
copyrat90 committed Jan 22, 2025
1 parent 7a6d88a commit cb0e708
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,31 @@ comments:
label: # OPTIONAL: Adds an issue label in the issue
```
#### Giscus
[Giscus](https://giscus.app/) is another open source alternative linked to one's GitHub account.
It stores the comments as GitHub discussions on a repository for each page.
Install the giscus [app](https://github.com/apps/giscus) to your repo.
After installing, add your info in the `_config.yml`:

```yaml
comments:
giscus: # Enable by filling below information. For more info, go to https://giscus.app
repo: # Your public comments repository (e.g. owner/repo)
repo-id: # Your repo id, go to https://giscus.app to check it
category: # Category to search discussions. When removed, discussions will be searched in all categories
category-id: # Your category id, go to https://giscus.app to check it
mapping: # Discussion mapping
term: # OPTIONAL: some mappings require specific term, go to https://giscus.app to check it
strict: 1 # OPTIONAL: Avoid mismatches on similar titles
reactions-enabled: 0 # OPTIONAL: Disable reactions
emit-metadata: 1 # OPTIONAL: Emit discussion metadata
input-position: top # OPTIONAL: Place the comment box above the comments
theme: # OPTIONAL: Take the `color_theme` by default, or set a custom one like github-dark-orange
lang: # OPTIONAL: Choose the language. "en" is used by default
```
### Math typesetting with KateX
When KateX is set in `_config.yml`:
Expand Down
6 changes: 6 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ comments:
utterances: # Enable by filling below information. For more info, go to https://utteranc.es
repo: # your public comments repository (e.g. owner/repo)
issue-term: # Issue term (e.g. "comment" consider issues with this word in the title as comments)
giscus: # Enable by filling below information. For more info, go to https://giscus.app
repo: # Your public comments repository (e.g. owner/repo)
repo-id: # Your repo id, go to https://giscus.app to check it
category: # Category to search discussions. When removed, discussions will be searched in all categories.
category-id: # Your category id, go to https://giscus.app to check it
mapping: # Discussion mapping

# PAGINATION
paginate: 5
Expand Down
5 changes: 5 additions & 0 deletions _includes/blog/post_footer.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
{% include blog/post_nav.liquid %}
{% endif %}

<!-- Giscus -->
{% if site.comments.giscus.repo and site.comments.giscus.repo-id and site.comments.giscus.category-id and site.comments.giscus.mapping %}
{% include social/giscus.liquid %}
{% endif %}

<!--Utterances-->
{% if site.comments.utterances.repo and site.comments.utterances.issue-term %}
{% include social/utterances.liquid %}
Expand Down
17 changes: 17 additions & 0 deletions _includes/social/giscus.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<script src="https://giscus.app/client.js"
data-repo="{{ site.comments.giscus.repo }}"
data-repo-id="{{ site.comments.giscus.repo-id }}"
{% if site.comments.giscus.category %}data-category="{{ site.comments.giscus.category }}"{% endif %}
data-category-id="{{ site.comments.giscus.category-id }}"
data-mapping="{{ site.comments.giscus.mapping }}"
{% if site.comments.giscus.term %}data-term="{{ site.comments.giscus.term }}"{% endif %}
data-strict="{% if site.comments.giscus.strict %}{{ site.comments.giscus.strict }}{% else %}0{% endif %}"
data-reactions-enabled="{% if site.comments.giscus.reactions-enabled %}{{ site.comments.giscus.reactions-enabled }}{% else %}1{% endif %}"
data-emit-metadata="{% if site.comments.giscus.emit-metadata %}{{ site.comments.giscus.emit-metadata }}{% else %}0{% endif %}"
data-input-position="{% if site.comments.giscus.input-position %}{{ site.comments.giscus.input-position }}{% else %}bottom{% endif %}"
data-theme="{% if site.comments.giscus.theme %}{{ site.comments.giscus.theme }}{% elsif site.color_theme == 'dark' %}dark{% else %}light{% endif %}"
data-lang="{% if site.comments.giscus.lang %}{{ site.comments.giscus.lang }}{% else %}en{% endif %}"
{% if site.comments.giscus.loading %}data-loading="{{ site.comments.giscus.loading }}"{% endif %}
crossorigin="anonymous"
async>
</script>

0 comments on commit cb0e708

Please sign in to comment.