giscus: Use specific search term instead of og:title

This makes us more flexible and gives us ways to avoid title collisions (e.g. when the title on an extra post is a substring of some post title).
This commit is contained in:
Philipp Oppermann
2021-06-12 16:35:20 +02:00
parent 90c4e2bb93
commit 47292beaad
6 changed files with 7 additions and 18 deletions

View File

@@ -20,8 +20,6 @@
<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,7 +3,6 @@
{% 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) }}
@@ -18,6 +17,6 @@
<hr> <hr>
<section> <section>
<h2 id="comments">Comments</h2> <h2 id="comments">Comments</h2>
{{ snippets::giscus() }} {{ snippets::giscus(search_term=page.title ~ " (Extra Post)") }}
</section> </section>
{% endblock after_main %} {% endblock after_main %}

View File

@@ -4,7 +4,6 @@
{% 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" -%}
@@ -104,7 +103,7 @@
</p> </p>
{% endif %} {% endif %}
{{ snippets::giscus() }} {{ snippets::giscus(search_term=page.title) }}
</section> </section>
<aside class="page-aside-right"> <aside class="page-aside-right">

View File

@@ -3,7 +3,6 @@
{% 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>
@@ -18,7 +17,7 @@
<hr> <hr>
<section> <section>
<h2 id="comments">Comments</h2> <h2 id="comments">Comments</h2>
{{ snippets::giscus() }} {{ snippets::giscus(search_term=page.title ~ " (News Post)") }}
</section> </section>
{% endblock after_main %} {% endblock after_main %}

View File

@@ -10,21 +10,16 @@
</p> </p>
{% endmacro support %} {% endmacro support %}
{% macro giscus(discussion_number=0) %} {% macro giscus(search_term) %}
<div class="giscus"></div> <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" <script src="https://giscus.app/client.js"
data-repo="phil-opp/blog_os" data-repo="phil-opp/blog_os"
data-repo-id="MDEwOlJlcG9zaXRvcnkzOTU3NTEwMQ==" data-repo-id="MDEwOlJlcG9zaXRvcnkzOTU3NTEwMQ=="
data-category="Post Comments" data-category="Post Comments"
data-category-id="MDE4OkRpc2N1c3Npb25DYXRlZ29yeTMzMDE4OTg1" data-category-id="MDE4OkRpc2N1c3Npb25DYXRlZ29yeTMzMDE4OTg1"
data-mapping="og:title" data-mapping="specific"
data-term="{{ search_term }}"
data-reactions-enabled="1" data-reactions-enabled="1"
data-theme="preferred_color_scheme" data-theme="preferred_color_scheme"
crossorigin="anonymous" crossorigin="anonymous"

View File

@@ -3,7 +3,6 @@
{% 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>
@@ -33,7 +32,7 @@
<hr> <hr>
<section> <section>
<h2 id="comments">Comments</h2> <h2 id="comments">Comments</h2>
{{ snippets::giscus() }} {{ snippets::giscus(search_term=page.title) }}
</section> </section>
{% endblock after_main %} {% endblock after_main %}