Skip to content

Commit 8893d48

Browse files
authored
Update giscus setup via github action (alshedivat#1792)
giscus settings in `_config.yml` had al-folio repo specified by default. many users kept these defaults in their own repos, which resulted in getting comments from blog posts of different users posted to al-folio discussions. this is undesirable, since users lose control over the discussions in their blogs. this PR solves the issue: - first, we set `giscus.repo` to blank in `_config.yml`. if the field is kept blank, when the website is built locally, the user will see a warning saying that giscus comments are misconfigured. - second, we add a step to the `deploy` workflow that writes repository name to `giscus.repo` in `_config.yml`. that way, even if `giscus.repo` field is left black or set to an incorrect repo, it gets correctly populated at deployment time. other small changes in this PR are small stylistic adjustments.
1 parent 2897382 commit 8893d48

File tree

7 files changed

+88
-80
lines changed

7 files changed

+88
-80
lines changed

.github/workflows/deploy.yml

+7
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ jobs:
2626
with:
2727
ruby-version: '3.2.2'
2828
bundler-cache: true
29+
- name: Update _config.yml ⚙️
30+
uses: fjogeleit/yaml-update-action@v0.13.1
31+
with:
32+
commitChange: false
33+
valueFile: '_config.yml'
34+
propertyPath: 'giscus.repo'
35+
value: ${{ github.repository }}
2936
- name: Install and Build 🔧
3037
run: |
3138
pip3 install --upgrade jupyter

_config.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,8 @@ related_blog_posts:
137137
# Follow instructions on https://giscus.app/ to setup for your repo to fill out
138138
# the information below.
139139
giscus:
140-
repo: alshedivat/al-folio # <your-github-user-name>/<your-github-repo-name>
141-
repo_id: MDEwOlJlcG9zaXRvcnk2MDAyNDM2NQ==
140+
repo: # <your-github-user-name>/<your-github-repo-name>
142141
category: Comments # name of the category under which discussions will be created
143-
category_id: DIC_kwDOA5PmLc4CTBt6
144142
mapping: title # identify discussions by post title
145143
strict: 1 # use strict identification mode
146144
reactions_enabled: 1 # enable (1) or disable (0) emoji reactions

_includes/giscus.html

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<div id="giscus_thread" style="max-width: {{ site.max_width }}; margin: 0 auto;">
1+
<div id="giscus_thread">
2+
{%- if site.giscus.repo -%}
23
<script>
34
let giscusTheme = localStorage.getItem("theme");
45
let giscusAttributes = {
@@ -24,4 +25,12 @@
2425
document.getElementById("giscus_thread").appendChild(giscusScript);
2526
</script>
2627
<noscript>Please enable JavaScript to view the <a href="http://giscus.app/?ref_noscript">comments powered by giscus.</a></noscript>
28+
{%- else -%}
29+
{% capture giscus_warning %}
30+
> ##### giscus comments misconfigured
31+
> Please follow instructions at [http://giscus.app](http://giscus.app) and update your giscus configuration.
32+
{: .block-danger }
33+
{% endcapture %}
34+
{{ giscus_warning | markdownify }}
35+
{%- endif -%}
2736
</div>

_layouts/page.html

+19-19
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@
22
layout: default
33
---
44
<!-- page.html -->
5-
<div class="post">
5+
<div class="post">
66

7-
<header class="post-header">
8-
<h1 class="post-title">{{ page.title }}</h1>
9-
<p class="post-description">{{ page.description }}</p>
10-
</header>
7+
<header class="post-header">
8+
<h1 class="post-title">{{ page.title }}</h1>
9+
<p class="post-description">{{ page.description }}</p>
10+
</header>
1111

12-
<article>
13-
{{ content }}
14-
</article>
12+
<article>
13+
{{ content }}
14+
</article>
1515

16-
{%- if page.related_publications != null and page.related_publications.size > 0 -%}
17-
{% assign publications = page.related_publications | replace: ", ", "," | split: "," | join: "|" %}
18-
<h2>References</h2>
19-
<div class="publications">
20-
{% bibliography -f {{ site.scholar.bibliography }} -q @*[key^={{ publications }}]* %}
21-
</div>
22-
{%- endif %}
16+
{%- if page.related_publications != null and page.related_publications.size > 0 -%}
17+
{% assign publications = page.related_publications | replace: ", ", "," | split: "," | join: "|" %}
18+
<h2>References</h2>
19+
<div class="publications">
20+
{% bibliography -f {{ site.scholar.bibliography }} -q @*[key^={{ publications }}]* %}
21+
</div>
22+
{%- endif %}
2323

24-
{%- if site.giscus.repo and page.giscus_comments -%}
25-
{% include giscus.html %}
26-
{%- endif -%}
27-
</div>
24+
{%- if site.giscus and page.giscus_comments -%}
25+
{% include giscus.html %}
26+
{%- endif -%}
27+
</div>

_layouts/post.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ <h2>References</h2>
6868
{%- if site.disqus_shortname and page.disqus_comments -%}
6969
{% include disqus.html %}
7070
{%- endif %}
71-
{%- if site.giscus.repo and page.giscus_comments -%}
71+
{%- if site.giscus and page.giscus_comments -%}
7272
{% include giscus.html %}
7373
{%- endif -%}
7474

_sass/_base.scss

+47-56
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,54 @@ img {
6262

6363
blockquote {
6464
background: var(--global-bg-color);
65-
border-left: 2px solid var(--global-theme-color);
66-
margin: 1.5em 10px;
67-
padding: 0.5em 10px;
65+
border-left: 5px solid var(--global-theme-color);
66+
margin: 1.5em 0;
67+
padding: 1em;
6868
font-size: 1.2rem;
69+
70+
p {
71+
margin-bottom: 0;
72+
}
73+
74+
/* Tips, warnings, and dangers blockquotes */
75+
&.block-tip {
76+
border-color: var(--global-tip-block);
77+
background-color: var(--global-tip-block-bg);
78+
79+
p {
80+
color: var(--global-tip-block-text);
81+
}
82+
83+
h1, h2, h3, h4, h5, h6 {
84+
color: var(--global-tip-block-title);
85+
}
86+
}
87+
88+
&.block-warning {
89+
border-color: var(--global-warning-block);
90+
background-color: var(--global-warning-block-bg);
91+
92+
p {
93+
color: var(--global-warning-block-text);
94+
}
95+
96+
h1, h2, h3, h4, h5, h6 {
97+
color: var(--global-warning-block-title);
98+
}
99+
}
100+
101+
&.block-danger {
102+
border-color: var(--global-danger-block);
103+
background-color: var(--global-danger-block-bg);
104+
105+
p {
106+
color: var(--global-danger-block-text);
107+
}
108+
109+
h1, h2, h3, h4, h5, h6 {
110+
color: var(--global-danger-block-title);
111+
}
112+
}
69113
}
70114

71115
// Math
@@ -814,17 +858,6 @@ html.transition *:after {
814858
}
815859
}
816860
}
817-
818-
.post-content {
819-
blockquote {
820-
border-left: 5px solid var(--global-theme-color);
821-
padding: 8px;
822-
823-
p {
824-
margin-bottom: 0;
825-
}
826-
}
827-
}
828861
}
829862

830863
progress {
@@ -994,48 +1027,6 @@ nav[data-toggle="toc"] {
9941027
}
9951028
}
9961029

997-
/* Tips, warnings, and dangers blockquotes */
998-
.post .post-content blockquote {
999-
&.block-tip {
1000-
border-color: var(--global-tip-block);
1001-
background-color: var(--global-tip-block-bg);
1002-
1003-
p {
1004-
color: var(--global-tip-block-text);
1005-
}
1006-
1007-
h1, h2, h3, h4, h5, h6 {
1008-
color: var(--global-tip-block-title);
1009-
}
1010-
}
1011-
1012-
&.block-warning {
1013-
border-color: var(--global-warning-block);
1014-
background-color: var(--global-warning-block-bg);
1015-
1016-
p {
1017-
color: var(--global-warning-block-text);
1018-
}
1019-
1020-
h1, h2, h3, h4, h5, h6 {
1021-
color: var(--global-warning-block-title);
1022-
}
1023-
}
1024-
1025-
&.block-danger {
1026-
border-color: var(--global-danger-block);
1027-
background-color: var(--global-danger-block-bg);
1028-
1029-
p {
1030-
color: var(--global-danger-block-text);
1031-
}
1032-
1033-
h1, h2, h3, h4, h5, h6 {
1034-
color: var(--global-danger-block-title);
1035-
}
1036-
}
1037-
}
1038-
10391030
.featured-posts {
10401031
a {
10411032
color: var(--global-text-color-light);

_sass/_distill.scss

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ d-article {
3434
b i {
3535
display: inline;
3636
}
37+
blockquote {
38+
border-left: 2px solid var(--global-theme-color) !important;
39+
}
3740

3841
// Style taken from code blocks
3942
details {

0 commit comments

Comments
 (0)