✨ feat: add support for Isso comments
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
{%- macro add_comments(comment_system, automatic_loading) -%}
|
||||
|
||||
<div id="comments" class="comments centered-text"
|
||||
<div id="comments" class="comments"
|
||||
|
||||
{% if comment_system == "giscus" %}
|
||||
{# Store required giscus data attributes in the div #}
|
||||
data-repo="{{ config.extra.giscus.repo }}"
|
||||
data-repo-id="{{ config.extra.giscus.repo_id }}"
|
||||
data-category="{{ config.extra.giscus.category }}"
|
||||
@@ -27,10 +27,10 @@
|
||||
{% else %}
|
||||
data-lang="{{ lang }}"
|
||||
{% endif %}
|
||||
data-lazy-loading="{{ config.extra.giscus.lazy_loading | default(value=true) }}">
|
||||
data-lazy-loading="{{ config.extra.giscus.lazy_loading }}"
|
||||
>
|
||||
|
||||
{% elif comment_system == "utterances" %}
|
||||
{# Store required utterances data attributes in the div #}
|
||||
data-repo="{{ config.extra.utterances.repo }}"
|
||||
{% if config.extra.utterances.issue_term == "slug" %}
|
||||
data-issue-term="{{ page.slug }}"
|
||||
@@ -40,10 +40,10 @@
|
||||
data-label="{{ config.extra.utterances.label }}"
|
||||
data-light-theme="{{ config.extra.utterances.light_theme }}"
|
||||
data-dark-theme="{{ config.extra.utterances.dark_theme }}"
|
||||
data-lazy-loading="{{ config.extra.utterances.lazy_loading | default(value=true) }}">
|
||||
data-lazy-loading="{{ config.extra.utterances.lazy_loading }}"
|
||||
>
|
||||
|
||||
{% elif comment_system == "hyvortalk" %}
|
||||
{# Store required Hyvor Talk data attributes in the div #}
|
||||
data-website-id="{{ config.extra.hyvortalk.website_id }}"
|
||||
{% if config.extra.hyvortalk.page_id_is_slug %}
|
||||
data-page-id="{{ page.slug }}"
|
||||
@@ -57,10 +57,30 @@
|
||||
{% endif %}
|
||||
data-page-author="{{ config.extra.hyvortalk.page_author }}"
|
||||
{% if config.extra.hyvortalk.lazy_loading %}
|
||||
data-loading="lazy">
|
||||
data-loading="lazy"
|
||||
{% else %}
|
||||
data-loading="default">
|
||||
data-loading="default"
|
||||
{% endif %}
|
||||
>
|
||||
|
||||
{% elif comment_system == "isso" %}
|
||||
data-endpoint-url="{{ config.extra.isso.endpoint_url }}"
|
||||
{% if config.extra.isso.page_id_is_slug %}
|
||||
data-isso-id="{{ page.slug }}"
|
||||
data-title="{{ page.slug }}"
|
||||
{% endif %}
|
||||
{% if config.extra.isso.lang %}
|
||||
data-page-language="{{ config.extra.isso.lang }}"
|
||||
{% else %}
|
||||
data-page-language="{{ lang }}"
|
||||
{% endif %}
|
||||
data-max-comments-top="{{ config.extra.isso.max_comments_top }}"
|
||||
data-max-comments-nested="{{ config.extra.isso.max_comments_nested }}"
|
||||
data-avatar="{{ config.extra.isso.avatar }}"
|
||||
data-voting="{{ config.extra.isso.voting }}"
|
||||
data-page-author-hashes="{{ config.extra.isso.page_author_hashes }}"
|
||||
data-lazy-loading="{{ config.extra.isso.lazy_loading }}"
|
||||
>
|
||||
{% endif %}
|
||||
|
||||
{% if automatic_loading %}
|
||||
|
@@ -84,16 +84,33 @@
|
||||
{% set giscus_enabled = config.extra.giscus.enabled_for_all_posts or page.extra.giscus %}
|
||||
{% set utterances_enabled = config.extra.utterances.enabled_for_all_posts or page.extra.utterances %}
|
||||
{% set hyvortalk_enabled = config.extra.hyvortalk.enabled_for_all_posts or page.extra.hyvortalk %}
|
||||
{% set isso_enabled = config.extra.isso.enabled_for_all_posts or page.extra.isso %}
|
||||
|
||||
{# Ensure only one comment system is enabled #}
|
||||
{% if giscus_enabled and utterances_enabled or giscus_enabled and hyvortalk_enabled or utterances_enabled and hyvortalk_enabled %}
|
||||
{{ throw(message="ERROR: Multiple comment systems have been enabled for the same page. Check your config.toml and individual page settings to ensure only one comment system is activated at a time.") }}
|
||||
{% elif giscus_enabled %}
|
||||
{# Counter for enabled comment systems #}
|
||||
{% set enabled_systems = 0 %}
|
||||
|
||||
{# Check and count the enabled comment systems #}
|
||||
{% if giscus_enabled %}
|
||||
{% set comment_system = "giscus" %}
|
||||
{% elif utterances_enabled %}
|
||||
{% set enabled_systems = enabled_systems + 1 %}
|
||||
{% endif %}
|
||||
{% if utterances_enabled %}
|
||||
{% set comment_system = "utterances" %}
|
||||
{% elif hyvortalk_enabled %}
|
||||
{% set enabled_systems = enabled_systems + 1 %}
|
||||
{% endif %}
|
||||
{% if hyvortalk_enabled %}
|
||||
{% set comment_system = "hyvortalk" %}
|
||||
{% set enabled_systems = enabled_systems + 1 %}
|
||||
{% endif %}
|
||||
{% if isso_enabled %}
|
||||
{% set comment_system = "isso" %}
|
||||
{% set enabled_systems = enabled_systems + 1 %}
|
||||
{% endif %}
|
||||
|
||||
{# Ensure only one comment system is enabled #}
|
||||
{% if enabled_systems > 1 %}
|
||||
{{ throw(message="ERROR: Multiple comment systems have been enabled for the same page. Check your config.toml and individual page settings to ensure only one comment system is activated at a time.") }}
|
||||
{% endif %}
|
||||
|
||||
{% if comment_system %}
|
||||
|
@@ -73,12 +73,15 @@
|
||||
{%- if config.extra.allowed_domains -%}
|
||||
;
|
||||
{# Check if a comment system is enabled to allow the necessary domains and directives #}
|
||||
{%- set utterances_enabled = config.extra.utterances.enabled_for_all_posts or page.extra.utterances -%}
|
||||
{%- set giscus_enabled = config.extra.giscus.enabled_for_all_posts or page.extra.giscus -%}
|
||||
{% set utterances_enabled = config.extra.utterances.enabled_for_all_posts or page.extra.utterances %}
|
||||
{% set giscus_enabled = config.extra.giscus.enabled_for_all_posts or page.extra.giscus %}
|
||||
{% set hyvortalk_enabled = config.extra.hyvortalk.enabled_for_all_posts or page.extra.hyvortalk %}
|
||||
{% set isso_enabled = config.extra.isso.enabled_for_all_posts or page.extra.isso %}
|
||||
|
||||
{% if hyvortalk_enabled %}
|
||||
connect-src talk.hyvor.com;
|
||||
{% elif isso_enabled %}
|
||||
connect-src {{ config.extra.isso.endpoint_url }};
|
||||
{% endif %}
|
||||
|
||||
{%- for domain in config.extra.allowed_domains -%}
|
||||
@@ -95,6 +98,11 @@
|
||||
{%- elif hyvortalk_enabled %} talk.hyvor.com
|
||||
{%- endif %}
|
||||
{%- endif -%}
|
||||
|
||||
{%- if domain.directive == "script-src" -%}
|
||||
{%- if isso_enabled %} {{ config.extra.isso.endpoint_url }}
|
||||
{%- endif %}
|
||||
{%- endif -%}
|
||||
{%- if not loop.last -%}
|
||||
;
|
||||
{%- endif -%}
|
||||
|
Reference in New Issue
Block a user