From 297989c1be175df46640a1547cc390e9442f527d Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Mon, 5 Jul 2021 16:08:28 -0400 Subject: [PATCH] Add giscus support (#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 --- CHANGELOG.md | 3 +++ README.md | 2 +- _config.yml | 9 ++++++- _includes/comments-providers/giscus.html | 24 +++++++++++++++++ _includes/comments-providers/scripts.html | 2 ++ _includes/comments.html | 3 +++ docs/_config.yml | 9 ++++++- docs/_docs/05-configuration.md | 32 ++++++++++++++++++++++- docs/_docs/18-history.md | 2 ++ docs/_pages/about.md | 2 +- test/_config.yml | 9 ++++++- 11 files changed, 91 insertions(+), 6 deletions(-) create mode 100644 _includes/comments-providers/giscus.html diff --git a/CHANGELOG.md b/CHANGELOG.md index f9328ee8..4ab3d492 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,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) ### Enhancements diff --git a/README.md b/README.md index eac36eca..99ecd839 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/_config.yml b/_config.yml index 2135c6f0..ed24c379 100644 --- a/_config.yml +++ b/_config.yml @@ -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: @@ -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 : # '1' for enabled (default), '0' for disabled + theme : # "light" (default), "dark", "dark_dimmed", "transparent_dark", "preferred_color_scheme" staticman: branch : # "master" endpoint : # "https://{your Staticman v3 API}/v3/entry/github/" diff --git a/_includes/comments-providers/giscus.html b/_includes/comments-providers/giscus.html new file mode 100644 index 00000000..e89d41ce --- /dev/null +++ b/_includes/comments-providers/giscus.html @@ -0,0 +1,24 @@ + \ No newline at end of file diff --git a/_includes/comments-providers/scripts.html b/_includes/comments-providers/scripts.html index c550618f..e87badab 100644 --- a/_includes/comments-providers/scripts.html +++ b/_includes/comments-providers/scripts.html @@ -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 %} diff --git a/_includes/comments.html b/_includes/comments.html index b23cea4d..4ff59e27 100644 --- a/_includes/comments.html +++ b/_includes/comments.html @@ -153,6 +153,9 @@ {% when "utterances" %}

{{ comments_label }}

+ {% when "giscus" %} +

{{ comments_label }}

+
{% when "custom" %} {% include /comments-providers/custom.html %} {% endcase %} diff --git a/docs/_config.yml b/docs/_config.yml index f3ac7cdb..d2dff4b0 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -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: @@ -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 : # '1' for enabled (default), '0' for disabled + theme : # "light" (default), "dark", "dark_dimmed", "transparent_dark", "preferred_color_scheme" reCaptcha: siteKey : # "6LdRBykTAAAAAFB46MnIu6ixuxwu9W1ihFF8G60Q" secret : # "PznnZGu3P6eTHRPLORniSq+J61YEf+A9zmColXDM5icqF49gbunH51B8+h+i2IvewpuxtA9TFoK68TuhUp/X3YKmmqhXasegHYabY50fqF9nJh9npWNhvITdkQHeaOqnFXUIwxfiEeUt49Yoa2waRR7a5LdRAP3SVM8hz0KIBT4=" diff --git a/docs/_docs/05-configuration.md b/docs/_docs/05-configuration.md index a427c9ce..6e04524d 100644 --- a/docs/_docs/05-configuration.md +++ b/docs/_docs/05-configuration.md @@ -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 and fill out the desired settings. This will generate JavaScript that will provide you with the settings you will need to configure things below. + +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 : # '1' for enabled (default), '0' for disabled + 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. diff --git a/docs/_docs/18-history.md b/docs/_docs/18-history.md index 192aac7b..a64cc8a2 100644 --- a/docs/_docs/18-history.md +++ b/docs/_docs/18-history.md @@ -24,6 +24,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 diff --git a/docs/_pages/about.md b/docs/_pages/about.md index 23221aad..09406fe6 100644 --- a/docs/_pages/about.md +++ b/docs/_pages/about.md @@ -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. diff --git a/test/_config.yml b/test/_config.yml index a9737894..2d09d966 100644 --- a/test/_config.yml +++ b/test/_config.yml @@ -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: @@ -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 : # '1' for enabled (default), '0' for disabled + theme : # "light" (default), "dark", "dark_dimmed", "transparent_dark", "preferred_color_scheme" staticman: branch : # "master" endpoint : # "https://{your Staticman v3 API}/v3/entry/github/"