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.
37 lines
1.5 KiB
HTML
37 lines
1.5 KiB
HTML
<div id="giscus_thread">
|
|
{%- if site.giscus.repo -%}
|
|
<script>
|
|
let giscusTheme = localStorage.getItem("theme");
|
|
let giscusAttributes = {
|
|
"src": "https://giscus.app/client.js",
|
|
"data-repo": "{{ site.giscus.repo }}",
|
|
"data-repo-id": "{{ site.giscus.repo_id }}",
|
|
"data-category": "{{ site.giscus.category }}",
|
|
"data-category-id": "{{ site.giscus.category_id }}",
|
|
"data-mapping": "{{ site.giscus.mapping }}",
|
|
"data-strict": "{{ site.giscus.strict }}",
|
|
"data-reactions-enabled": "{{ site.giscus.reactions_enabled }}",
|
|
"data-emit-metadata": "{{ site.giscus.emit_metadata }}",
|
|
"data-input-position": "{{ site.giscus.input_position }}",
|
|
"data-theme": giscusTheme,
|
|
"data-lang": "{{ site.giscus.lang }}",
|
|
"crossorigin": "anonymous",
|
|
"async": "",
|
|
};
|
|
|
|
|
|
let giscusScript = document.createElement("script");
|
|
Object.entries(giscusAttributes).forEach(([key, value]) => giscusScript.setAttribute(key, value));
|
|
document.getElementById("giscus_thread").appendChild(giscusScript);
|
|
</script>
|
|
<noscript>Please enable JavaScript to view the <a href="http://giscus.app/?ref_noscript">comments powered by giscus.</a></noscript>
|
|
{%- 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 -%}
|
|
</div>
|