Skip to content

Commit

Permalink
Add more configuration for Giscus (mmistakes#4274)
Browse files Browse the repository at this point in the history
* update giscus

* fix site variable name

---------

Co-authored-by: Andrii Burkatskyi <underr-ua@users.noreply.github.com>
  • Loading branch information
2 people authored and minyoongi96 committed Aug 26, 2024
1 parent 6d17a42 commit 1f394bf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down
12 changes: 11 additions & 1 deletion _includes/comments-providers/giscus.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
})();
</script>
</script>

0 comments on commit 1f394bf

Please sign in to comment.