From 409bc9286817982e748d21e4d64b0d40b1261be0 Mon Sep 17 00:00:00 2001 From: Andrii B <10338746+akaunderr@users.noreply.github.com> Date: Tue, 23 Apr 2024 08:53:52 +0300 Subject: [PATCH] Add more configuration for Giscus (#4274) * update giscus * fix site variable name --------- Co-authored-by: Andrii Burkatskyi --- _config.yml | 5 +++++ _includes/comments-providers/giscus.html | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/_config.yml b/_config.yml index aa3c9bcf..5c1a4303 100644 --- a/_config.yml +++ b/_config.yml @@ -52,6 +52,11 @@ comments: discussion_term : # "pathname" (default), "url", "title", "og:title" reactions_enabled : # '1' for enabled (default), '0' for disabled theme : # "light" (default), "dark", "dark_dimmed", "transparent_dark", "preferred_color_scheme" + strict : # 1 for enabled, 0 for disabled (default) + input_position : # "top", "bottom" # The comment input box will be placed above or below the comments + emit_metadata : # 1 for enabled, 0 for disabled (default) # https://github.com/giscus/giscus/blob/main/ADVANCED-USAGE.md#imetadatamessage + lang : # "en" (default) + lazy : # true, false # Loading of the comments will be deferred until the user scrolls near the comments container. staticman: branch : # "master" endpoint : # "https://{your Staticman v3 API}/v3/entry/github/" diff --git a/_includes/comments-providers/giscus.html b/_includes/comments-providers/giscus.html index e89d41ce..a4f6365a 100644 --- a/_includes/comments-providers/giscus.html +++ b/_includes/comments-providers/giscus.html @@ -9,16 +9,26 @@ } var script = document.createElement('script'); + script.setAttribute('src', 'https://giscus.app/client.js'); script.setAttribute('data-repo', '{{ site.repository | downcase }}'); script.setAttribute('data-repo-id', '{{ site.comments.giscus.repo_id }}'); script.setAttribute('data-category', '{{ site.comments.giscus.category_name }}'); script.setAttribute('data-category-id', '{{ site.comments.giscus.category_id }}'); script.setAttribute('data-mapping', '{{ site.comments.giscus.discussion_term | default: "pathname" }}'); + script.setAttribute('data-strict', '{{ site.comments.giscus.strict | default: 0 }}'); script.setAttribute('data-reactions-enabled', '{{ site.comments.giscus.reactions_enabled | default: 1 }}'); + script.setAttribute('data-emit-metadata', '{{ site.comments.giscus.emit_metadata | default: 0 }}'); + script.setAttribute('data-input-position', '{{ site.comments.giscus.input_position | default: "top" }}'); script.setAttribute('data-theme', '{{ site.comments.giscus.theme | default: "light" }}'); + script.setAttribute('data-lang', '{{ site.comments.giscus.lang | default: "en" }}'); + {% if site.comments.giscus.lazy %} + script.setAttribute('data-loading', 'lazy'); + {% endif %} script.setAttribute('crossorigin', 'anonymous'); + script.setAttribute('async', ''); + commentContainer.appendChild(script); })(); - \ No newline at end of file +