Skip to content

Commit 297989c

Browse files
authoredJul 5, 2021
Add giscus support (mmistakes#3022)
* Add script in same style as utterances But adjusted for the various filed differences * Add initial script * Add default settings * Update changelog * Add feature to readme * Add comments html * add comment provider include * update config in docs * Add URL for additional reference * docs for giscus comments * Unrelated bugfix: add missing version separator So that things match the "history" doc. * add space * update history doc * update about doc * add to test config yaml * remove unnecessary / incorrect async attribute * probably should pass the right config paths * lowercase the repo name * Update docs to address '1' and '0' for reactions_enabled Figured I'd match the giscus format rather than convert a boolean to an int there. * update two additional docs * docs wording fix
1 parent 8adb089 commit 297989c

File tree

11 files changed

+91
-6
lines changed

11 files changed

+91
-6
lines changed
 

‎CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
- Remove `h2` from skip links navigation as it is not important for site structure. [#3012](https://github.com/mmistakes/minimal-mistakes/pull/3012)
1414
- Loads Font Awesome asynchronously. [#2967](https://github.com/mmistakes/minimal-mistakes/pull/2967)
1515
- Replace custom search icon SVG with Font Awesome icon. [#2774](https://github.com/mmistakes/minimal-mistakes/pull/2774)
16+
- Adds support for giscus comments. [#3022](https://github.com/mmistakes/minimal-mistakes/pull/3022)
17+
18+
## [4.23.0](https://github.com/mmistakes/minimal-mistakes/releases/tag/4.23.0)
1619

1720
### Enhancements
1821

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Minimal Mistakes is a flexible two-column Jekyll theme, perfect for building per
3333
- Several responsive layout options (single, archive index, search, splash, and paginated home page).
3434
- Optimized for search engines with support for [Twitter Cards](https://dev.twitter.com/cards/overview) and [Open Graph](http://ogp.me/) data.
3535
- Optional [header images](https://mmistakes.github.io/minimal-mistakes/docs/layouts/#headers), [custom sidebars](https://mmistakes.github.io/minimal-mistakes/docs/layouts/#sidebars), [table of contents](https://mmistakes.github.io/minimal-mistakes/docs/helpers/#table-of-contents), [galleries](https://mmistakes.github.io/minimal-mistakes/docs/helpers/#gallery), related posts, [breadcrumb links](https://mmistakes.github.io/minimal-mistakes/docs/configuration/#breadcrumb-navigation-beta), [navigation lists](https://mmistakes.github.io/minimal-mistakes/docs/helpers/#navigation-list), and more.
36-
- Commenting support (powered by [Disqus](https://disqus.com/), [Facebook](https://developers.facebook.com/docs/plugins/comments), Google+, [Discourse](https://www.discourse.org/), static-based via [Staticman](https://staticman.net/), and [utterances](https://utteranc.es/)).
36+
- Commenting support (powered by [Disqus](https://disqus.com/), [Facebook](https://developers.facebook.com/docs/plugins/comments), Google+, [Discourse](https://www.discourse.org/), static-based via [Staticman](https://staticman.net/), [utterances](https://utteranc.es/), and [giscus](https://giscus.app/)).
3737
- [Google Analytics](https://www.google.com/analytics/) support.
3838
- UI localized text in English (default), Arabic (عربي), Brazilian Portuguese (Português brasileiro), Catalan, Chinese, Danish, Dutch, Finnish, French (Français), German (Deutsch), Greek, Hebrew, Hindi (हिंदी), Hungarian, Indonesian, Irish (Gaeilge), Italian (Italiano), Japanese, Korean, Malayalam, Myanmar (Burmese), Nepali (Nepalese), Norwegian (Norsk), Persian (فارسی), Polish, Punjabi (ਪੰਜਾਬੀ), Romanian, Russian, Slovak, Spanish (Español), Swedish, Thai, Turkish (Türkçe), and Vietnamese.
3939

‎_config.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ masthead_title : # overrides the website title displayed in the masthe
3030
# breadcrumbs : false # true, false (default)
3131
words_per_minute : 200
3232
comments:
33-
provider : # false (default), "disqus", "discourse", "facebook", "staticman", "staticman_v2", "utterances", "custom"
33+
provider : # false (default), "disqus", "discourse", "facebook", "staticman", "staticman_v2", "utterances", "giscus", "custom"
3434
disqus:
3535
shortname : # https://help.disqus.com/customer/portal/articles/466208-what-s-a-shortname-
3636
discourse:
@@ -43,6 +43,13 @@ comments:
4343
utterances:
4444
theme : # "github-light" (default), "github-dark"
4545
issue_term : # "pathname" (default)
46+
giscus:
47+
repo_id : # Shown during giscus setup at https://giscus.app
48+
category_name : # Full text name of the category
49+
category_id : # Shown during giscus setup at https://giscus.app
50+
discussion_term : # "pathname" (default), "url", "title", "og:title"
51+
reactions_enabled : # '1' for enabled (default), '0' for disabled
52+
theme : # "light" (default), "dark", "dark_dimmed", "transparent_dark", "preferred_color_scheme"
4653
staticman:
4754
branch : # "master"
4855
endpoint : # "https://{your Staticman v3 API}/v3/entry/github/"
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<script>
2+
'use strict';
3+
4+
(function () {
5+
var commentContainer = document.querySelector('#giscus-comments');
6+
7+
if (!commentContainer) {
8+
return;
9+
}
10+
11+
var script = document.createElement('script');
12+
script.setAttribute('src', 'https://giscus.app/client.js');
13+
script.setAttribute('data-repo', '{{ site.repository | downcase }}');
14+
script.setAttribute('data-repo-id', '{{ site.comments.giscus.repo_id }}');
15+
script.setAttribute('data-category', '{{ site.comments.giscus.category_name }}');
16+
script.setAttribute('data-category-id', '{{ site.comments.giscus.category_id }}');
17+
script.setAttribute('data-mapping', '{{ site.comments.giscus.discussion_term | default: "pathname" }}');
18+
script.setAttribute('data-reactions-enabled', '{{ site.comments.giscus.reactions_enabled | default: 1 }}');
19+
script.setAttribute('data-theme', '{{ site.comments.giscus.theme | default: "light" }}');
20+
script.setAttribute('crossorigin', 'anonymous');
21+
22+
commentContainer.appendChild(script);
23+
})();
24+
</script>

‎_includes/comments-providers/scripts.html

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
{% include /comments-providers/staticman_v2.html %}
1313
{% when "utterances" %}
1414
{% include /comments-providers/utterances.html %}
15+
{% when "giscus" %}
16+
{% include /comments-providers/giscus.html %}
1517
{% when "custom" %}
1618
{% include /comments-providers/custom_scripts.html %}
1719
{% endcase %}

‎_includes/comments.html

+3
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ <h4 class="page__comments-title">{{ site.data.ui-text[site.locale].comments_labe
153153
{% when "utterances" %}
154154
<h4 class="page__comments-title">{{ comments_label }}</h4>
155155
<section id="utterances-comments"></section>
156+
{% when "giscus" %}
157+
<h4 class="page__comments-title">{{ comments_label }}</h4>
158+
<section id="giscus-comments"></section>
156159
{% when "custom" %}
157160
{% include /comments-providers/custom.html %}
158161
{% endcase %}

‎docs/_config.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ masthead_title : # overrides the website title displayed in the masthe
2525
# breadcrumbs : false # true, false (default)
2626
words_per_minute : 200
2727
comments:
28-
provider : "false" # false (default), "disqus", "discourse", "facebook", "staticman_v2", "staticman", "utterances", "custom"
28+
provider : "false" # false (default), "disqus", "discourse", "facebook", "staticman_v2", "staticman", "utterances", "giscus", "custom"
2929
disqus:
3030
shortname :
3131
discourse:
@@ -38,6 +38,13 @@ comments:
3838
utterances:
3939
theme : # "github-light" (default), "github-dark"
4040
issue_term : # "pathname" (default)
41+
giscus:
42+
repo_id : # Shown during giscus setup at https://giscus.app
43+
category_name : # Full text name of the category
44+
category_id : # Shown during giscus setup at https://giscus.app
45+
discussion_term : # "pathname" (default), "url", "title", "og:title"
46+
reactions_enabled : # '1' for enabled (default), '0' for disabled
47+
theme : # "light" (default), "dark", "dark_dimmed", "transparent_dark", "preferred_color_scheme"
4148
reCaptcha:
4249
siteKey : # "6LdRBykTAAAAAFB46MnIu6ixuxwu9W1ihFF8G60Q"
4350
secret : # "PznnZGu3P6eTHRPLORniSq+J61YEf+A9zmColXDM5icqF49gbunH51B8+h+i2IvewpuxtA9TFoK68TuhUp/X3YKmmqhXasegHYabY50fqF9nJh9npWNhvITdkQHeaOqnFXUIwxfiEeUt49Yoa2waRR7a5LdRAP3SVM8hz0KIBT4="

‎docs/_docs/05-configuration.md

+31-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ For example,
333333

334334
### Comments
335335

336-
[**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:
336+
[**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:
337337

338338
| Name | Comment Provider |
339339
| ---------------- | ------------------------- |
@@ -343,6 +343,7 @@ For example,
343343
| **staticman_v2** | Staticman v2 / v3 |
344344
| **staticman** | Staticman v1 (deprecated) |
345345
| **utterances** | utterances |
346+
| **giscus** | giscus |
346347
| **custom** | Other |
347348

348349
Then add `comments: true` to each document you want comments visible on.
@@ -424,6 +425,35 @@ comments:
424425
issue_term: "pathname"
425426
```
426427

428+
#### giscus comments
429+
430+
To use giscus you will need to [install the app](https://github.com/apps/giscus) to your GitHub repository.
431+
432+
The next step is to go to <https://giscus.app> and fill out the desired settings. This will generate JavaScript that will provide you with the settings you will need to configure things below.
433+
434+
You'll need to ensure you've added the following to `_config.yml`:
435+
436+
```yaml
437+
repository: # GitHub username/repo-name e.g. "mmistakes/minimal-mistakes"
438+
```
439+
440+
**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.
441+
{: .notice--warning}
442+
443+
To enable giscus on the front end set `comments.provider` and the other additional options.
444+
445+
```yaml
446+
comments:
447+
provider: "giscus"
448+
giscus:
449+
repo_id : # Shown during giscus setup at https://giscus.app
450+
category_name : # Full text name of the category
451+
category_id : # Shown during giscus setup at https://giscus.app
452+
discussion_term : # "pathname" (default), "url", "title", "og:title"
453+
reactions_enabled : # '1' for enabled (default), '0' for disabled
454+
theme : # "light" (default), "dark", "dark_dimmed", "transparent_dark", "preferred_color_scheme"
455+
```
456+
427457
#### Static-based comments via Staticman
428458

429459
Transform user comments into `_data` files that live inside of your GitHub repository by enabling Staticman.

‎docs/_docs/18-history.md

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ toc: false
2424
- Remove `h2` from skip links navigation as it is not important for site structure. [#3012](https://github.com/mmistakes/minimal-mistakes/pull/3012)
2525
- Loads Font Awesome asynchronously. [#2967](https://github.com/mmistakes/minimal-mistakes/pull/2967)
2626
- Replace custom search icon SVG with Font Awesome icon. [#2774](https://github.com/mmistakes/minimal-mistakes/pull/2774)
27+
- Adds support for giscus comments. [#3022](https://github.com/mmistakes/minimal-mistakes/pull/3022)
28+
2729
## [4.23.0](https://github.com/mmistakes/minimal-mistakes/releases/tag/4.23.0)
2830

2931
### Enhancements

‎docs/_pages/about.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Minimal Mistakes is a flexible two-column Jekyll theme. Perfect for hosting your
3131
- Several responsive layout options (single, archive index, search, splash, and paginated home page).
3232
- Optimized for search engines with support for [Twitter Cards](https://dev.twitter.com/cards/overview) and [Open Graph](http://ogp.me/) data
3333
- Optional [header images](https://mmistakes.github.io/minimal-mistakes/docs/layouts/#headers), [custom sidebars](https://mmistakes.github.io/minimal-mistakes/docs/layouts/#sidebars), [table of contents](https://mmistakes.github.io/minimal-mistakes/docs/helpers/#table-of-contents), [galleries](https://mmistakes.github.io/minimal-mistakes/docs/helpers/#gallery), related posts, [breadcrumb links](https://mmistakes.github.io/minimal-mistakes/docs/configuration/#breadcrumb-navigation-beta), [navigation lists](https://mmistakes.github.io/minimal-mistakes/docs/helpers/#navigation-list), and more.
34-
- Commenting support (powered by [Disqus](https://disqus.com/), [Facebook](https://developers.facebook.com/docs/plugins/comments), [Discourse](https://www.discourse.org/), [utterances](https://utteranc.es/), static-based via [Staticman v1 and v2](https://staticman.net/), and custom).
34+
- Commenting support (powered by [Disqus](https://disqus.com/), [Facebook](https://developers.facebook.com/docs/plugins/comments), [Discourse](https://www.discourse.org/), [utterances](https://utteranc.es/), [giscus](https://giscus.app/), static-based via [Staticman v1 and v2](https://staticman.net/), and custom).
3535
- [Google Analytics](https://www.google.com/analytics/) support.
3636
- UI localized text in English (default), Arabic (عربي), Brazilian Portuguese (Português brasileiro), Catalan, Chinese, Danish, Dutch, Finnish, French (Français), German (Deutsch), Greek, Hebrew, Hindi (हिंदी), Hungarian, Indonesian, Irish (Gaeilge), Italian (Italiano), Japanese, Korean, Malayalam, Myanmar (Burmese), Nepali (Nepalese), Norwegian (Norsk), Persian (فارسی), Polish, Punjabi (ਪੰਜਾਬੀ), Romanian, Russian, Slovak, Spanish (Español), Swedish, Thai, Turkish (Türkçe), and Vietnamese.
3737

‎test/_config.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ masthead_title : "Custom Title" # overrides the website title displaye
2424
# breadcrumbs : false # true, false (default)
2525
words_per_minute : 200
2626
comments:
27-
provider : # false (default), "disqus", "discourse", "facebook", "staticman", "utterances", "custom"
27+
provider : # false (default), "disqus", "discourse", "facebook", "staticman", "utterances", "giscus", "custom"
2828
disqus:
2929
shortname : # https://help.disqus.com/customer/portal/articles/466208-what-s-a-shortname-
3030
discourse:
@@ -37,6 +37,13 @@ comments:
3737
utterances:
3838
theme : # "github-light" (default), "github-dark"
3939
issue_term : # "pathname" (default)
40+
giscus:
41+
repo_id : # Shown during giscus setup at https://giscus.app
42+
category_name : # Full text name of the category
43+
category_id : # Shown during giscus setup at https://giscus.app
44+
discussion_term : # "pathname" (default), "url", "title", "og:title"
45+
reactions_enabled : # '1' for enabled (default), '0' for disabled
46+
theme : # "light" (default), "dark", "dark_dimmed", "transparent_dark", "preferred_color_scheme"
4047
staticman:
4148
branch : # "master"
4249
endpoint : # "https://{your Staticman v3 API}/v3/entry/github/"

0 commit comments

Comments
 (0)
Please sign in to comment.