Add more configuration for Giscus (#4274)

* update giscus

* fix site variable name

---------

Co-authored-by: Andrii Burkatskyi <underr-ua@users.noreply.github.com>
This commit is contained in:
Andrii B 2024-04-23 08:53:52 +03:00 committed by GitHub
parent f8527e7916
commit 409bc92868
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View File

@ -52,6 +52,11 @@ comments:
discussion_term : # "pathname" (default), "url", "title", "og:title" discussion_term : # "pathname" (default), "url", "title", "og:title"
reactions_enabled : # '1' for enabled (default), '0' for disabled reactions_enabled : # '1' for enabled (default), '0' for disabled
theme : # "light" (default), "dark", "dark_dimmed", "transparent_dark", "preferred_color_scheme" 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: staticman:
branch : # "master" branch : # "master"
endpoint : # "https://{your Staticman v3 API}/v3/entry/github/" endpoint : # "https://{your Staticman v3 API}/v3/entry/github/"

View File

@ -9,16 +9,26 @@
} }
var script = document.createElement('script'); var script = document.createElement('script');
script.setAttribute('src', 'https://giscus.app/client.js'); script.setAttribute('src', 'https://giscus.app/client.js');
script.setAttribute('data-repo', '{{ site.repository | downcase }}'); script.setAttribute('data-repo', '{{ site.repository | downcase }}');
script.setAttribute('data-repo-id', '{{ site.comments.giscus.repo_id }}'); script.setAttribute('data-repo-id', '{{ site.comments.giscus.repo_id }}');
script.setAttribute('data-category', '{{ site.comments.giscus.category_name }}'); script.setAttribute('data-category', '{{ site.comments.giscus.category_name }}');
script.setAttribute('data-category-id', '{{ site.comments.giscus.category_id }}'); script.setAttribute('data-category-id', '{{ site.comments.giscus.category_id }}');
script.setAttribute('data-mapping', '{{ site.comments.giscus.discussion_term | default: "pathname" }}'); 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-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-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('crossorigin', 'anonymous');
script.setAttribute('async', '');
commentContainer.appendChild(script); commentContainer.appendChild(script);
})(); })();
</script> </script>