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

Add giscus support #3022

Merged
merged 21 commits into from
Jul 5, 2021
Merged
Show file tree
Hide file tree
Changes from 18 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
- Remove `h2` from skip links navigation as it is not important for site structure. [#3012](https://github.com/mmistakes/minimal-mistakes/pull/3012)
- Loads Font Awesome asynchronously. [#2967](https://github.com/mmistakes/minimal-mistakes/pull/2967)
- Replace custom search icon SVG with Font Awesome icon. [#2774](https://github.com/mmistakes/minimal-mistakes/pull/2774)
- Adds support for giscus comments. [#3022](https://github.com/mmistakes/minimal-mistakes/pull/3022)

## [4.23.0](https://github.com/mmistakes/minimal-mistakes/releases/tag/4.23.0)
Copy link
Contributor Author

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.


### Enhancements

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Minimal Mistakes is a flexible two-column Jekyll theme, perfect for building per
- Several responsive layout options (single, archive index, search, splash, and paginated home page).
- Optimized for search engines with support for [Twitter Cards](https://dev.twitter.com/cards/overview) and [Open Graph](http://ogp.me/) data.
- 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.
- 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/)).
- 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/)).
- [Google Analytics](https://www.google.com/analytics/) support.
- 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.

Expand Down
9 changes: 8 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ masthead_title : # overrides the website title displayed in the masthe
# breadcrumbs : false # true, false (default)
words_per_minute : 200
comments:
provider : # false (default), "disqus", "discourse", "facebook", "staticman", "staticman_v2", "utterances", "custom"
provider : # false (default), "disqus", "discourse", "facebook", "staticman", "staticman_v2", "utterances", "giscus", "custom"
disqus:
shortname : # https://help.disqus.com/customer/portal/articles/466208-what-s-a-shortname-
discourse:
Expand All @@ -43,6 +43,13 @@ comments:
utterances:
theme : # "github-light" (default), "github-dark"
issue_term : # "pathname" (default)
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"
staticman:
branch : # "master"
endpoint : # "https://{your Staticman v3 API}/v3/entry/github/"
Expand Down
24 changes: 24 additions & 0 deletions _includes/comments-providers/giscus.html
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>
2 changes: 2 additions & 0 deletions _includes/comments-providers/scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
{% include /comments-providers/staticman_v2.html %}
{% when "utterances" %}
{% include /comments-providers/utterances.html %}
{% when "giscus" %}
{% include /comments-providers/giscus.html %}
{% when "custom" %}
{% include /comments-providers/custom_scripts.html %}
{% endcase %}
Expand Down
3 changes: 3 additions & 0 deletions _includes/comments.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ <h4 class="page__comments-title">{{ site.data.ui-text[site.locale].comments_labe
{% when "utterances" %}
<h4 class="page__comments-title">{{ comments_label }}</h4>
<section id="utterances-comments"></section>
{% when "giscus" %}
<h4 class="page__comments-title">{{ comments_label }}</h4>
<section id="giscus-comments"></section>
{% when "custom" %}
{% include /comments-providers/custom.html %}
{% endcase %}
Expand Down
9 changes: 8 additions & 1 deletion docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ masthead_title : # overrides the website title displayed in the masthe
# breadcrumbs : false # true, false (default)
words_per_minute : 200
comments:
provider : "false" # false (default), "disqus", "discourse", "facebook", "staticman_v2", "staticman", "utterances", "custom"
provider : "false" # false (default), "disqus", "discourse", "facebook", "staticman_v2", "staticman", "utterances", "giscus", "custom"
disqus:
shortname :
discourse:
Expand All @@ -38,6 +38,13 @@ comments:
utterances:
theme : # "github-light" (default), "github-dark"
issue_term : # "pathname" (default)
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"
reCaptcha:
siteKey : # "6LdRBykTAAAAAFB46MnIu6ixuxwu9W1ihFF8G60Q"
secret : # "PznnZGu3P6eTHRPLORniSq+J61YEf+A9zmColXDM5icqF49gbunH51B8+h+i2IvewpuxtA9TFoK68TuhUp/X3YKmmqhXasegHYabY50fqF9nJh9npWNhvITdkQHeaOqnFXUIwxfiEeUt49Yoa2waRR7a5LdRAP3SVM8hz0KIBT4="
Expand Down
32 changes: 31 additions & 1 deletion docs/_docs/05-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
| ---------------- | ------------------------- |
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Copy link
Owner

Choose a reason for hiding this comment

The 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.
Expand Down
2 changes: 2 additions & 0 deletions docs/_docs/18-history.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ toc: false
- Remove `h2` from skip links navigation as it is not important for site structure. [#3012](https://github.com/mmistakes/minimal-mistakes/pull/3012)
- Loads Font Awesome asynchronously. [#2967](https://github.com/mmistakes/minimal-mistakes/pull/2967)
- Replace custom search icon SVG with Font Awesome icon. [#2774](https://github.com/mmistakes/minimal-mistakes/pull/2774)
- Adds support for giscus comments. [#3022](https://github.com/mmistakes/minimal-mistakes/pull/3022)

## [4.23.0](https://github.com/mmistakes/minimal-mistakes/releases/tag/4.23.0)

### Enhancements
Expand Down
2 changes: 1 addition & 1 deletion docs/_pages/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Minimal Mistakes is a flexible two-column Jekyll theme. Perfect for hosting your
- Several responsive layout options (single, archive index, search, splash, and paginated home page).
- Optimized for search engines with support for [Twitter Cards](https://dev.twitter.com/cards/overview) and [Open Graph](http://ogp.me/) data
- 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.
- 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).
- 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).
- [Google Analytics](https://www.google.com/analytics/) support.
- 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.

Expand Down
9 changes: 8 additions & 1 deletion test/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ masthead_title : "Custom Title" # overrides the website title displaye
# breadcrumbs : false # true, false (default)
words_per_minute : 200
comments:
provider : # false (default), "disqus", "discourse", "facebook", "staticman", "utterances", "custom"
provider : # false (default), "disqus", "discourse", "facebook", "staticman", "utterances", "giscus", "custom"
disqus:
shortname : # https://help.disqus.com/customer/portal/articles/466208-what-s-a-shortname-
discourse:
Expand All @@ -37,6 +37,13 @@ comments:
utterances:
theme : # "github-light" (default), "github-dark"
issue_term : # "pathname" (default)
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"
staticman:
branch : # "master"
endpoint : # "https://{your Staticman v3 API}/v3/entry/github/"
Expand Down