Merge pull request #1116 from phil-opp/fix-comment-threads

Move comment threads for translated posts to separate category
This commit is contained in:
Philipp Oppermann
2022-06-07 10:08:13 +02:00
committed by GitHub
5 changed files with 20 additions and 7 deletions

View File

@@ -17,6 +17,6 @@
<hr>
<section>
<h2 id="comments">Comments</h2>
{{ snippets::giscus(search_term=page.title ~ " (Extra Post)") }}
{{ snippets::giscus(search_term=page.title ~ " (Extra Post)", translated=false) }}
</section>
{% endblock after_main %}

View File

@@ -118,7 +118,12 @@
{% else %}
{% set search_term=page.title %}
{% endif %}
{{ snippets::giscus(search_term=search_term) }}
{% if page.lang != "en" %}
{% set translated = true %}
{% else %}
{% set translated = false %}
{% endif %}
{{ snippets::giscus(search_term=search_term, translated=translated) }}
{%- if page.lang != "en" %}
<p class="{% if page.extra.rtl %}right-to-left{% endif %}">

View File

@@ -17,7 +17,7 @@
<hr>
<section>
<h2 id="comments">Comments</h2>
{{ snippets::giscus(search_term=page.title ~ " (News Post)") }}
{{ snippets::giscus(search_term=page.title ~ " (News Post)", translated=false) }}
</section>
{% endblock after_main %}

View File

@@ -10,12 +10,20 @@
</p>
{% endmacro support %}
{% macro giscus(search_term) %}
{% macro giscus(search_term, translated) %}
{% if translated %}
{% set category = "Post Comments" %}
{% set category_path = "post-comments" %}
{% else %}
{% set category = "Post Comments (translated)" %}
{% set category_path = "post-comments-translated" %}
{% endif %}
{% if search_term is number %}
{% set discussion_url = "https://github.com/phil-opp/blog_os/discussions/" ~ search_term %}
{% else %}
{% set search_term_encoded = `"` ~ search_term ~ `"` | urlencode %}
{% set discussion_url = `https://github.com/phil-opp/blog_os/discussions/categories/post-comments?discussions_q=` ~ search_term_encoded %}
{% set discussion_url = `https://github.com/phil-opp/blog_os/discussions/categories/` ~ category_path ~ `?discussions_q=` ~ search_term_encoded %}
{% endif %}
<p class="comment-note">
@@ -27,7 +35,7 @@
<script src="https://giscus.app/client.js"
data-repo="phil-opp/blog_os"
data-repo-id="MDEwOlJlcG9zaXRvcnkzOTU3NTEwMQ=="
data-category="Post Comments"
data-category="{{ category }}"
data-category-id="MDE4OkRpc2N1c3Npb25DYXRlZ29yeTMzMDE4OTg1"
{% if search_term is number %}
data-mapping="number"

View File

@@ -32,7 +32,7 @@
<hr>
<section>
<h2 id="comments">Comments</h2>
{{ snippets::giscus(search_term=page.title) }}
{{ snippets::giscus(search_term=page.title, translated=false) }}
</section>
{% endblock after_main %}