From 8893d483bc331049b140fdca5d4ab2f329375d08 Mon Sep 17 00:00:00 2001 From: Maruan Date: Wed, 4 Oct 2023 22:27:36 -0400 Subject: [PATCH] Update giscus setup via github action (#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. --- .github/workflows/deploy.yml | 7 +++ _config.yml | 4 +- _includes/giscus.html | 11 +++- _layouts/page.html | 38 ++++++------- _layouts/post.html | 2 +- _sass/_base.scss | 103 ++++++++++++++++------------------- _sass/_distill.scss | 3 + 7 files changed, 88 insertions(+), 80 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index dd50706f719b..ba61f8a84be2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -26,6 +26,13 @@ jobs: with: ruby-version: '3.2.2' bundler-cache: true + - name: Update _config.yml ⚙️ + uses: fjogeleit/yaml-update-action@v0.13.1 + with: + commitChange: false + valueFile: '_config.yml' + propertyPath: 'giscus.repo' + value: ${{ github.repository }} - name: Install and Build 🔧 run: | pip3 install --upgrade jupyter diff --git a/_config.yml b/_config.yml index 401c6d1f9f5b..6c76cfe91e16 100644 --- a/_config.yml +++ b/_config.yml @@ -137,10 +137,8 @@ related_blog_posts: # Follow instructions on https://giscus.app/ to setup for your repo to fill out # the information below. giscus: - repo: alshedivat/al-folio # / - repo_id: MDEwOlJlcG9zaXRvcnk2MDAyNDM2NQ== + repo: # / category: Comments # name of the category under which discussions will be created - category_id: DIC_kwDOA5PmLc4CTBt6 mapping: title # identify discussions by post title strict: 1 # use strict identification mode reactions_enabled: 1 # enable (1) or disable (0) emoji reactions diff --git a/_includes/giscus.html b/_includes/giscus.html index bb504f64dbb8..433b16c308d4 100644 --- a/_includes/giscus.html +++ b/_includes/giscus.html @@ -1,4 +1,5 @@ -
+
+ {%- if site.giscus.repo -%} + {%- else -%} + {% capture giscus_warning %} + > ##### giscus comments misconfigured + > Please follow instructions at [http://giscus.app](http://giscus.app) and update your giscus configuration. + {: .block-danger } + {% endcapture %} + {{ giscus_warning | markdownify }} + {%- endif -%}
diff --git a/_layouts/page.html b/_layouts/page.html index dec6cb6c23b7..f2fd877d6937 100644 --- a/_layouts/page.html +++ b/_layouts/page.html @@ -2,26 +2,26 @@ layout: default --- -
+
-
-

{{ page.title }}

-

{{ page.description }}

-
+
+

{{ page.title }}

+

{{ page.description }}

+
-
- {{ content }} -
+
+ {{ content }} +
- {%- if page.related_publications != null and page.related_publications.size > 0 -%} - {% assign publications = page.related_publications | replace: ", ", "," | split: "," | join: "|" %} -

References

-
- {% bibliography -f {{ site.scholar.bibliography }} -q @*[key^={{ publications }}]* %} -
- {%- endif %} + {%- if page.related_publications != null and page.related_publications.size > 0 -%} + {% assign publications = page.related_publications | replace: ", ", "," | split: "," | join: "|" %} +

References

+
+ {% bibliography -f {{ site.scholar.bibliography }} -q @*[key^={{ publications }}]* %} +
+ {%- endif %} - {%- if site.giscus.repo and page.giscus_comments -%} - {% include giscus.html %} - {%- endif -%} -
+ {%- if site.giscus and page.giscus_comments -%} + {% include giscus.html %} + {%- endif -%} +
diff --git a/_layouts/post.html b/_layouts/post.html index 46ade06c8e90..0a1e0947ef4a 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -68,7 +68,7 @@

References

{%- if site.disqus_shortname and page.disqus_comments -%} {% include disqus.html %} {%- endif %} - {%- if site.giscus.repo and page.giscus_comments -%} + {%- if site.giscus and page.giscus_comments -%} {% include giscus.html %} {%- endif -%} diff --git a/_sass/_base.scss b/_sass/_base.scss index a69981b7f128..095d68c8862e 100644 --- a/_sass/_base.scss +++ b/_sass/_base.scss @@ -62,10 +62,54 @@ img { blockquote { background: var(--global-bg-color); - border-left: 2px solid var(--global-theme-color); - margin: 1.5em 10px; - padding: 0.5em 10px; + border-left: 5px solid var(--global-theme-color); + margin: 1.5em 0; + padding: 1em; font-size: 1.2rem; + + p { + margin-bottom: 0; + } + + /* Tips, warnings, and dangers blockquotes */ + &.block-tip { + border-color: var(--global-tip-block); + background-color: var(--global-tip-block-bg); + + p { + color: var(--global-tip-block-text); + } + + h1, h2, h3, h4, h5, h6 { + color: var(--global-tip-block-title); + } + } + + &.block-warning { + border-color: var(--global-warning-block); + background-color: var(--global-warning-block-bg); + + p { + color: var(--global-warning-block-text); + } + + h1, h2, h3, h4, h5, h6 { + color: var(--global-warning-block-title); + } + } + + &.block-danger { + border-color: var(--global-danger-block); + background-color: var(--global-danger-block-bg); + + p { + color: var(--global-danger-block-text); + } + + h1, h2, h3, h4, h5, h6 { + color: var(--global-danger-block-title); + } + } } // Math @@ -814,17 +858,6 @@ html.transition *:after { } } } - - .post-content { - blockquote { - border-left: 5px solid var(--global-theme-color); - padding: 8px; - - p { - margin-bottom: 0; - } - } - } } progress { @@ -994,48 +1027,6 @@ nav[data-toggle="toc"] { } } -/* Tips, warnings, and dangers blockquotes */ -.post .post-content blockquote { - &.block-tip { - border-color: var(--global-tip-block); - background-color: var(--global-tip-block-bg); - - p { - color: var(--global-tip-block-text); - } - - h1, h2, h3, h4, h5, h6 { - color: var(--global-tip-block-title); - } - } - - &.block-warning { - border-color: var(--global-warning-block); - background-color: var(--global-warning-block-bg); - - p { - color: var(--global-warning-block-text); - } - - h1, h2, h3, h4, h5, h6 { - color: var(--global-warning-block-title); - } - } - - &.block-danger { - border-color: var(--global-danger-block); - background-color: var(--global-danger-block-bg); - - p { - color: var(--global-danger-block-text); - } - - h1, h2, h3, h4, h5, h6 { - color: var(--global-danger-block-title); - } - } -} - .featured-posts { a { color: var(--global-text-color-light); diff --git a/_sass/_distill.scss b/_sass/_distill.scss index e8c05f04e4e4..f08954198ee0 100644 --- a/_sass/_distill.scss +++ b/_sass/_distill.scss @@ -34,6 +34,9 @@ d-article { b i { display: inline; } + blockquote { + border-left: 2px solid var(--global-theme-color) !important; + } // Style taken from code blocks details {