Merge pull request #996 from phil-opp/giscus

Switch comments from utterances to giscus
This commit is contained in:
Philipp Oppermann
2021-06-12 16:14:12 +02:00
committed by GitHub
7 changed files with 41 additions and 10 deletions

View File

@@ -462,3 +462,11 @@ a strong {
.status-update-list li { .status-update-list li {
margin-bottom: .5rem; margin-bottom: .5rem;
} }
#comments {
visibility: hidden;
}
.comment-directly-on-github {
margin-top: 1rem;
}

View File

@@ -20,6 +20,8 @@
<script async src="/js/edition-2/main.js"></script> <script async src="/js/edition-2/main.js"></script>
<title>{% block title %}{% endblock title %}</title> <title>{% block title %}{% endblock title %}</title>
{% block head %}{% endblock head %}
</head> </head>
<body> <body>

View File

@@ -3,6 +3,7 @@
{% import "snippets.html" as snippets %} {% import "snippets.html" as snippets %}
{% block title %}{{ page.title }} | {{ config.title }}{% endblock title %} {% block title %}{{ page.title }} | {{ config.title }}{% endblock title %}
{% block head %}<meta property="og:title" content="{{ page.title }}" />{% endblock head %}
{% block description -%} {% block description -%}
{{ page.summary | safe | striptags | truncate(length=150) }} {{ page.summary | safe | striptags | truncate(length=150) }}
@@ -16,7 +17,7 @@
{% block after_main %} {% block after_main %}
<hr> <hr>
<section> <section>
<h2>Comments</h2> <h2 id="comments">Comments</h2>
{{ snippets::utterances() }} {{ snippets::giscus() }}
</section> </section>
{% endblock after_main %} {% endblock after_main %}

View File

@@ -4,6 +4,8 @@
{% import "snippets.html" as snippets %} {% import "snippets.html" as snippets %}
{% block title %}{{ page.title }} | {{ config.title }}{% endblock title %} {% block title %}{{ page.title }} | {{ config.title }}{% endblock title %}
{% block head %}<meta property="og:title" content="{{ page.title }}" />{% endblock head %}
{% block header %} {% block header %}
{% if lang != "en" -%} {% if lang != "en" -%}
<aside id="all-posts-link"><a href="{{ config.base_url | safe }}/{{ lang }}" title="All Posts">{{ trans(key="all_posts", lang=lang) }}</a></aside> <aside id="all-posts-link"><a href="{{ config.base_url | safe }}/{{ lang }}" title="All Posts">{{ trans(key="all_posts", lang=lang) }}</a></aside>
@@ -102,7 +104,7 @@
</p> </p>
{% endif %} {% endif %}
{{ snippets::utterances() }} {{ snippets::giscus() }}
</section> </section>
<aside class="page-aside-right"> <aside class="page-aside-right">

View File

@@ -3,6 +3,7 @@
{% import "snippets.html" as snippets %} {% import "snippets.html" as snippets %}
{% block title %}{{ page.title }} | {{ config.title }}{% endblock title %} {% block title %}{{ page.title }} | {{ config.title }}{% endblock title %}
{% block head %}<meta property="og:title" content="{{ page.title }}" />{% endblock head %}
{% block main %} {% block main %}
<h1>{{ page.title }}</h1> <h1>{{ page.title }}</h1>
@@ -17,7 +18,7 @@
<hr> <hr>
<section> <section>
<h2 id="comments">Comments</h2> <h2 id="comments">Comments</h2>
{{ snippets::utterances() }} {{ snippets::giscus() }}
</section> </section>
{% endblock after_main %} {% endblock after_main %}

View File

@@ -10,12 +10,28 @@
</p> </p>
{% endmacro support %} {% endmacro support %}
{% macro utterances() %} {% macro giscus(discussion_number=0) %}
<script src="https://utteranc.es/client.js" <div class="giscus"></div>
{% if discussion_number == 0 %}
{% set discussion_mapping="og:title" %}
{% else %}
{% set discussion_mapping="number" %}
{% endif %}
<script src="https://giscus.app/client.js"
data-repo="phil-opp/blog_os" data-repo="phil-opp/blog_os"
data-issue-term="url" data-repo-id="MDEwOlJlcG9zaXRvcnkzOTU3NTEwMQ=="
data-label="comments" data-category="Post Comments"
data-category-id="MDE4OkRpc2N1c3Npb25DYXRlZ29yeTMzMDE4OTg1"
data-mapping="og:title"
data-reactions-enabled="1"
data-theme="preferred_color_scheme"
crossorigin="anonymous" crossorigin="anonymous"
async> async>
</script> </script>
{% endmacro utterances %}
<p class="comment-directly-on-github">
Instead of authenticating the <a href="https://giscus.app">giscus</a> application, you can also comment directly on the <span class="discussion_link">on GitHub. Just click the <i>"X comments"</i> link at the <a href="#comments">top</a> — or the date of any comment — to go to the GitHub discussion.</span>
</p>
{% endmacro giscus %}

View File

@@ -3,6 +3,7 @@
{% import "snippets.html" as snippets %} {% import "snippets.html" as snippets %}
{% block title %}{{ page.title }} | {{ config.title }}{% endblock title %} {% block title %}{{ page.title }} | {{ config.title }}{% endblock title %}
{% block head %}<meta property="og:title" content="{{ page.title }}" />{% endblock head %}
{% block main %} {% block main %}
<h1>{{ page.title }}</h1> <h1>{{ page.title }}</h1>
@@ -32,7 +33,7 @@
<hr> <hr>
<section> <section>
<h2 id="comments">Comments</h2> <h2 id="comments">Comments</h2>
{{ snippets::utterances() }} {{ snippets::giscus() }}
</section> </section>
{% endblock after_main %} {% endblock after_main %}