{% set automatic_loading = config.extra[comment_system].automatic_loading %}

<div id="comments" class="comments"

{% if comment_system == "giscus" %}
    data-repo="{{ config.extra.giscus.repo }}"
    data-repo-id="{{ config.extra.giscus.repo_id }}"
    data-category="{{ config.extra.giscus.category }}"
    data-category-id="{{ config.extra.giscus.category_id }}"
    {% if config.extra.giscus.mapping == "slug" %}
        data-mapping="specific"
        data-term="{{ page.slug }}"
    {% else %}
        data-mapping="{{ config.extra.giscus.mapping }}"
    {% endif %}
    data-strict="{{ config.extra.giscus.strict_title_matching }}"
    data-reactions-enabled="{{ config.extra.giscus.enable_reactions }}"
    {% if config.extra.giscus.comment_box_above_comments %}
        data-input-position="top"
    {% else %}
        data-input-position="bottom"
    {% endif %}
    data-light-theme="{{ config.extra.giscus.light_theme }}"
    data-dark-theme="{{ config.extra.giscus.dark_theme }}"
    {% if config.extra.giscus.lang  %}
        data-lang="{{ config.extra.giscus.lang }}"
    {% else %}
        data-lang="{{ lang }}"
    {% endif %}
    data-lazy-loading="{{ config.extra.giscus.lazy_loading }}"
    >

{% elif comment_system == "utterances" %}
    data-repo="{{ config.extra.utterances.repo }}"
    {% if config.extra.utterances.issue_term == "slug" %}
        data-issue-term="{{ page.slug }}"
    {% else %}
        data-issue-term="{{ config.extra.utterances.issue_term }}"
    {% endif %}
    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 }}"
    >

{% elif comment_system == "hyvortalk" %}
    data-website-id="{{ config.extra.hyvortalk.website_id }}"
    {% if config.extra.hyvortalk.page_id_is_slug %}
        data-page-id="{{ page.slug }}"
    {% else %}
        data-page-id="{{ current_url }}"
    {% endif %}
    {% if config.extra.hyvortalk.lang  %}
        data-page-language="{{ config.extra.hyvortalk.lang }}"
    {% else %}
        data-page-language="{{ lang }}"
    {% endif %}
    data-page-author="{{ config.extra.hyvortalk.page_author }}"
    {% if config.extra.hyvortalk.lazy_loading  %}
        data-loading="lazy"
    {% else %}
        data-loading="default"
    {% endif %}
    >

{% elif comment_system == "isso" %}
    data-endpoint-url="{{ config.extra.isso.endpoint_url }}"
    {% if config.extra.isso.page_id_is_slug %}
    {%- set default_lang_url = current_path | replace(from='/' ~ lang ~ '/', to = '/') -%}
        data-isso-id="{{ default_lang_url }}"
        data-title="{{ default_lang_url }}"
    {% 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 %}
    <script src="{{ get_url(path='js/' ~ comment_system ~ '.min.js', trailing_slash=false) | safe }}" async></script>
{% else %}
    <button id="load-comments" class="load-comments-button" data-script-src="{{ get_url(path='js/' ~ comment_system ~ '.min.js', trailing_slash=false) | safe }}">{{ macros_translate::translate(key="load_comments", default="Load comments", language_strings=language_strings) }}</button>
    <script src="{{ get_url(path='js/loadComments.min.js', trailing_slash=false) | safe }}" async></script>
{% endif %}

<noscript>You need JavaScript to view the comments.</noscript>
</div>
