Skip to content

Commit 015dcb8

Browse files
authored
Merge pull request #504 from sylhare/giscus
Giscus
2 parents 7025e6c + b79620c commit 015dcb8

8 files changed

Lines changed: 75 additions & 45 deletions

File tree

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Here are the main files of the template
6868
├── _config.yml # sample configuration
6969
├── _data
7070
| ├── authors.yml # Update the post authors configurations
71+
| ├── comments.yml # Comments configuration (Disqus, Cusdis, Utterances, Giscus)
7172
| ├── language.yml # Localization configuration
7273
| ├── biblio.yml # To create a reference bibliography
7374
| ├── social.yml # Social configurations to share posts (RSS, shares, ...)
@@ -183,12 +184,15 @@ It will use the [Google Tag Manager](https://support.google.com/analytics/answer
183184

184185
### Comments 💬
185186

187+
Type-on-Strap supports multiple comment systems.
188+
Use `_data/comments.yml` for all comment configurations
189+
186190
#### Disqus
187191

188192
If you have a [Disqus](https://disqus.com/) account, you can show a comments section below each post.
189193

190194
To enable Disqus comments, add your [Disqus shortname](https://help.disqus.com/customer/portal/articles/466208)
191-
to your project's `_config.yml` file:
195+
to your project's `_data/comments.yml.yml` file:
192196

193197
```yml
194198
comments:
@@ -200,7 +204,7 @@ comments:
200204
[Cusdis](https://cusdis.com/) is an open-source alternative to Disqus.
201205
You can read more about it in the [documentation](https://cusdis.com/doc#/)
202206

203-
To enable it, set your Cusdis name in `_config.yml`:
207+
To enable it, set your Cusdis name in `_data/comments.yml.yml`:
204208

205209
```yaml
206210
comments:
@@ -213,7 +217,7 @@ comments:
213217
It stores the comments as GitHub issues on a repository for each page.
214218

215219
Install the utterance [app](https://github.com/apps/utterances) to your repo.
216-
After installing, add your info in the `_config.yml`:
220+
After installing, add your info in the `_data/comments.yml.yml`:
217221

218222
```yaml
219223
comments:
@@ -230,7 +234,7 @@ comments:
230234
It stores the comments as GitHub discussions on a repository for each page.
231235
232236
Install the giscus [app](https://github.com/apps/giscus) to your repo.
233-
After installing, add your info in the `_config.yml`:
237+
After installing, add your info in the `_data/comments.yml.yml`:
234238

235239
```yaml
236240
comments:

_config.yml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,14 @@ post_navigation: true
2121
color_image: /assets/img/lineart.png # A bit transparent for color posts.
2222

2323
# Features
24-
# More in the _data folder for share buttons, author and language
24+
# More in the _data folder for comments, share buttons, author and language
2525
# For layout customization, go to the "_sass > base" folder, and check "_variables.scss"
2626
katex: true # Enable if using math markup
2727
mermaid: default # Enable mermaid-js for diagrams, use theme: base, forest, dark, default, neutral
2828
google_analytics: # Measurement ID, e.g. "G-00000"
2929
cookie_consent: false # To respect the usage of cookies
3030
color_theme: auto # auto, dark or light
3131

32-
# Comments options
33-
comments:
34-
disqus_shortname: # Your discus shortname for comments
35-
cusdis_app_id: # Your cusdis data-app-id
36-
utterances: # Enable by filling below information. For more info, go to https://utteranc.es
37-
repo: # your public comments repository (e.g. owner/repo)
38-
issue-term: # Issue term (e.g. "comment" consider issues with this word in the title as comments)
39-
giscus: # Enable by filling below information. For more info, go to https://giscus.app
40-
repo: # Your public comments repository (e.g. owner/repo)
41-
repo-id: # Your repo id, go to https://giscus.app to check it
42-
category: # Category to search discussions. When removed, discussions will be searched in all categories.
43-
category-id: # Your category id, go to https://giscus.app to check it
44-
mapping: # Discussion mapping
45-
4632
# PAGINATION
4733
paginate: 5
4834
paginate_path: "/blog/page:num"

_data/comments.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Comments configuration
2+
# Configure different comment systems here
3+
4+
# Disqus configuration
5+
disqus:
6+
shortname: # Your Disqus shortname
7+
8+
# Cusdis configuration
9+
cusdis:
10+
app_id: # Your Cusdis app ID
11+
lang: # Language code (e.g., zh-cn, es, tr, pt-BR)
12+
13+
# Utterances configuration
14+
utterances:
15+
repo: # Your public comments repository (e.g. owner/repo)
16+
issue-term: # Issue term (e.g. "comment" - considers issues with this word in the title as comments)
17+
theme: # OPTIONAL: Take the `color_theme` by default, or set a custom one like github-dark-orange
18+
label: # OPTIONAL: Adds an issue label in the issue
19+
20+
# Giscus configuration
21+
giscus:
22+
repo: # Your public comments repository (e.g. owner/repo)
23+
repo-id: # Your repo id, go to https://giscus.app to check it
24+
category: # Category to search discussions. When removed, discussions will be searched in all categories
25+
category-id: # Your category id, go to https://giscus.app to check it
26+
mapping: # Discussion mapping (e.g. pathname, url, title, og:title)
27+
term: # OPTIONAL: Some mappings require specific term, go to https://giscus.app to check it
28+
strict: 0 # OPTIONAL: Avoid mismatches on similar titles (0 or 1)
29+
reactions-enabled: 1 # OPTIONAL: Enable reactions (0 or 1)
30+
emit-metadata: 0 # OPTIONAL: Emit discussion metadata (0 or 1)
31+
input-position: bottom # OPTIONAL: Place the comment box (top or bottom)
32+
theme: # OPTIONAL: Take the `color_theme` by default, or set a custom one like dark_dimmed
33+
lang: en # OPTIONAL: Choose the language. "en" is used by default
34+
loading: # OPTIONAL: Loading behavior (lazy or eager)

_includes/blog/post_footer.liquid

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,28 @@
4040
{% endif %}
4141

4242
<!-- Giscus -->
43-
{% if site.comments.giscus.repo and site.comments.giscus.repo-id and site.comments.giscus.category-id and site.comments.giscus.mapping %}
43+
{% if site.data.comments.giscus.repo and site.data.comments.giscus.repo-id and site.data.comments.giscus.category-id and site.data.comments.giscus.mapping %}
4444
{% include social/giscus.liquid %}
4545
{% endif %}
4646

4747
<!--Utterances-->
48-
{% if site.comments.utterances.repo and site.comments.utterances.issue-term %}
48+
{% if site.data.comments.utterances.repo and site.data.comments.utterances.issue-term %}
49+
{% include social/utterances.liquid %}
50+
{% elsif site.comments.utterances.repo and site.comments.utterances.issue-term %}
4951
{% include social/utterances.liquid %}
5052
{% endif %}
5153

5254
<!-- Cusdis -->
53-
{% if site.comments.cusdis_app_id or site.cusdis_app_id %}
55+
{% if site.data.comments.cusdis.app_id %}
56+
{% include social/cusdis.liquid %}
57+
{% elsif site.comments.cusdis_app_id or site.cusdis_app_id %}
5458
{% include social/cusdis.liquid %}
5559
{% endif %}
5660

5761
<!-- Disqus -->
58-
{% if site.comments.disqus_shortname or site.theme_settings.disqus_shortname or site.disqus_shortname %}
62+
{% if site.data.comments.disqus.shortname %}
63+
{% include social/disqus.liquid %}
64+
{% elsif site.comments.disqus_shortname or site.theme_settings.disqus_shortname or site.disqus_shortname %}
5965
{% include social/disqus.liquid %}
6066
{% endif %}
6167
{% endcapture %}

_includes/social/cusdis.liquid

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<div class="comments" id="cusdis_thread"
22
data-host="https://cusdis.com"
3-
data-app-id="{% if site.comments.cusdis_app_id %}{{ site.comments.cusdis_app_id }}{% else %}{{ site.cusdis_app_id }}{% endif %}"
3+
data-app-id="{% if site.data.comments.cusdis.app_id %}{{ site.data.comments.cusdis.app_id }}{% elsif site.comments.cusdis_app_id %}{{ site.comments.cusdis_app_id }}{% else %}{{ site.cusdis_app_id }}{% endif %}"
44
data-page-id="{{ page.relative_path }}"
55
data-page-url="{{ page.url | absolute_url }}"
66
data-page-title="{{ page.title }}"
77
data-theme="{{ site.color_theme }}"
88
></div>
99

10-
{% if site.data.language.cusdis_lang %}
11-
<script defer src="https://cusdis.com/js/widget/lang/{{ site.data.language.cusdis_lang }}.js"></script>
10+
{% if site.data.comments.cusdis.lang or site.data.language.cusdis_lang %}
11+
<script defer src="https://cusdis.com/js/widget/lang/{% if site.data.comments.cusdis.lang %}{{ site.data.comments.cusdis.lang }}{% else %}{{ site.data.language.cusdis_lang }}{% endif %}.js"></script>
1212
{% endif %}
1313
<script defer src="https://cusdis.com/js/cusdis.es.js"></script>

_includes/social/disqus.liquid

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<div class="comments">
22
<div id="disqus_thread"></div>
33
<script type="text/javascript">
4-
var disqus_shortname = '{{ site.comments.disqus_shortname }}' || '{{ site.disqus_shortname }}';
4+
var disqus_shortname = '{{ site.data.comments.disqus.shortname }}' || '{{ site.comments.disqus_shortname }}' || '{{ site.disqus_shortname }}';
55
(function() {
66
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
77
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
88
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
99
})();
1010
</script>
11-
<noscript>{{ site.data.language.str_javascript_required_disqus | default: Please enable JavaScript to view comments." }}</noscript>
11+
<noscript>{{ site.data.language.str_javascript_required_disqus | default: "Please enable JavaScript to view comments." }}</noscript>
1212
</div>

_includes/social/giscus.liquid

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<script src="https://giscus.app/client.js"
2-
data-repo="{{ site.comments.giscus.repo }}"
3-
data-repo-id="{{ site.comments.giscus.repo-id }}"
4-
{% if site.comments.giscus.category %}data-category="{{ site.comments.giscus.category }}"{% endif %}
5-
data-category-id="{{ site.comments.giscus.category-id }}"
6-
data-mapping="{{ site.comments.giscus.mapping }}"
7-
{% if site.comments.giscus.term %}data-term="{{ site.comments.giscus.term }}"{% endif %}
8-
data-strict="{% if site.comments.giscus.strict %}{{ site.comments.giscus.strict }}{% else %}0{% endif %}"
9-
data-reactions-enabled="{% if site.comments.giscus.reactions-enabled %}{{ site.comments.giscus.reactions-enabled }}{% else %}1{% endif %}"
10-
data-emit-metadata="{% if site.comments.giscus.emit-metadata %}{{ site.comments.giscus.emit-metadata }}{% else %}0{% endif %}"
11-
data-input-position="{% if site.comments.giscus.input-position %}{{ site.comments.giscus.input-position }}{% else %}bottom{% endif %}"
12-
data-theme="{% if site.comments.giscus.theme %}{{ site.comments.giscus.theme }}{% elsif site.color_theme == 'dark' %}dark{% else %}light{% endif %}"
13-
data-lang="{% if site.comments.giscus.lang %}{{ site.comments.giscus.lang }}{% else %}en{% endif %}"
14-
{% if site.comments.giscus.loading %}data-loading="{{ site.comments.giscus.loading }}"{% endif %}
2+
data-repo="{{ site.data.comments.giscus.repo }}"
3+
data-repo-id="{{ site.data.comments.giscus.repo-id }}"
4+
{% if site.data.comments.giscus.category %}data-category="{{ site.data.comments.giscus.category }}"{% endif %}
5+
data-category-id="{{ site.data.comments.giscus.category-id }}"
6+
data-mapping="{{ site.data.comments.giscus.mapping }}"
7+
{% if site.data.comments.giscus.term %}data-term="{{ site.data.comments.giscus.term }}"{% endif %}
8+
data-strict="{% if site.data.comments.giscus.strict %}{{ site.data.comments.giscus.strict }}{% else %}0{% endif %}"
9+
data-reactions-enabled="{% if site.data.comments.giscus.reactions-enabled %}{{ site.data.comments.giscus.reactions-enabled }}{% else %}1{% endif %}"
10+
data-emit-metadata="{% if site.data.comments.giscus.emit-metadata %}{{ site.data.comments.giscus.emit-metadata }}{% else %}0{% endif %}"
11+
data-input-position="{% if site.data.comments.giscus.input-position %}{{ site.data.comments.giscus.input-position }}{% else %}bottom{% endif %}"
12+
data-theme="{% if site.data.comments.giscus.theme %}{{ site.data.comments.giscus.theme }}{% elsif site.color_theme == 'dark' %}dark{% else %}light{% endif %}"
13+
data-lang="{% if site.data.comments.giscus.lang %}{{ site.data.comments.giscus.lang }}{% else %}en{% endif %}"
14+
{% if site.data.comments.giscus.loading %}data-loading="{{ site.data.comments.giscus.loading }}"{% endif %}
1515
crossorigin="anonymous"
1616
async>
1717
</script>

_includes/social/utterances.liquid

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<script src="https://utteranc.es/client.js"
2-
repo='{{ site.comments.utterances.repo }}'
3-
issue-term="{{ site.comments.utterances.issue-term}}"
4-
theme="{% if site.comments.utterances.theme %}{{ site.comments.utterances.theme }}{% elsif site.color_theme == 'dark' %}github-dark{% else %}github-light{% endif %}"
5-
{% if site.comments.utterances.label %}label="{{ site.comments.utterances.label }}"{% endif %}
2+
repo='{% if site.data.comments.utterances.repo %}{{ site.data.comments.utterances.repo }}{% else %}{{ site.comments.utterances.repo }}{% endif %}'
3+
issue-term="{% if site.data.comments.utterances.issue-term %}{{ site.data.comments.utterances.issue-term }}{% else %}{{ site.comments.utterances.issue-term }}{% endif %}"
4+
theme="{% if site.data.comments.utterances.theme %}{{ site.data.comments.utterances.theme }}{% elsif site.comments.utterances.theme %}{{ site.comments.utterances.theme }}{% elsif site.color_theme == 'dark' %}github-dark{% else %}github-light{% endif %}"
5+
{% if site.data.comments.utterances.label or site.comments.utterances.label %}label="{% if site.data.comments.utterances.label %}{{ site.data.comments.utterances.label }}{% else %}{{ site.comments.utterances.label }}{% endif %}"{% endif %}
66
crossorigin="anonymous"
77
async>
88
</script>

0 commit comments

Comments
 (0)