✨ feat: add quick navigation buttons
💄 style(dark): change inline code background ♻️ refactor: simplify comment system logicmain
parent
6c8d5c750f
commit
05a6d15455
@ -1,71 +1,54 @@
|
|||||||
{%- macro add_comments() -%}
|
{%- macro add_comments(comment_system, automatic_loading) -%}
|
||||||
|
|
||||||
{% set giscus_enabled = config.extra.giscus.enabled_for_all_posts or page.extra.giscus %}
|
<div id="comments" class="comments centered-text"
|
||||||
{% set utterances_enabled = config.extra.utterances.enabled_for_all_posts or page.extra.utterances %}
|
{% if comment_system == "giscus" %}
|
||||||
|
{# Store required giscus data attributes in the div #}
|
||||||
{# Ensure only one comment system is enabled #}
|
data-repo="{{ config.extra.giscus.repo }}"
|
||||||
{% if giscus_enabled and utterances_enabled %}
|
data-repo-id="{{ config.extra.giscus.repo_id }}"
|
||||||
{{ 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.") }}
|
data-category="{{ config.extra.giscus.category }}"
|
||||||
|
data-category-id="{{ config.extra.giscus.category_id }}"
|
||||||
{% elif giscus_enabled %}
|
{% if config.extra.giscus.mapping == "slug" %}
|
||||||
<div class="comments centered-text"
|
data-mapping="specific"
|
||||||
{# Store required giscus data attributes in the div #}
|
data-term="{{ page.slug }}"
|
||||||
data-repo="{{ config.extra.giscus.repo }}"
|
{% else %}
|
||||||
data-repo-id="{{ config.extra.giscus.repo_id }}"
|
data-mapping="{{ config.extra.giscus.mapping }}"
|
||||||
data-category="{{ config.extra.giscus.category }}"
|
{% endif %}
|
||||||
data-category-id="{{ config.extra.giscus.category_id }}"
|
data-strict="{{ config.extra.giscus.strict_title_matching }}"
|
||||||
{% if config.extra.giscus.mapping == "slug" %}
|
data-reactions-enabled="{{ config.extra.giscus.enable_reactions }}"
|
||||||
data-mapping="specific"
|
{% if config.extra.giscus.comment_box_above_comments %}
|
||||||
data-term="{{ page.slug }}"
|
data-input-position="top"
|
||||||
{% else %}
|
{% else %}
|
||||||
data-mapping="{{ config.extra.giscus.mapping }}"
|
data-input-position="bottom"
|
||||||
{% endif %}
|
{% endif %}
|
||||||
data-strict="{{ config.extra.giscus.strict_title_matching }}"
|
data-light-theme="{{ config.extra.giscus.light_theme }}"
|
||||||
data-reactions-enabled="{{ config.extra.giscus.enable_reactions }}"
|
data-dark-theme="{{ config.extra.giscus.dark_theme }}"
|
||||||
{% if config.extra.giscus.comment_box_above_comments %}
|
{% if config.extra.giscus.lang %}
|
||||||
data-input-position="top"
|
data-lang="{{ config.extra.giscus.lang }}"
|
||||||
{% else %}
|
{% else %}
|
||||||
data-input-position="bottom"
|
data-lang="{{ lang }}"
|
||||||
{% endif %}
|
{% endif %}
|
||||||
data-light-theme="{{ config.extra.giscus.light_theme }}"
|
data-lazy-loading="{{ config.extra.giscus.lazy_loading | default(value=true) }}">
|
||||||
data-dark-theme="{{ config.extra.giscus.dark_theme }}"
|
|
||||||
{% if config.extra.giscus.lang %}
|
{% elif comment_system == "utterances" %}
|
||||||
data-lang="{{ config.extra.giscus.lang }}"
|
{# Store required utterances data attributes in the div #}
|
||||||
{% else %}
|
data-repo="{{ config.extra.utterances.repo }}"
|
||||||
data-lang="{{ lang }}"
|
{% if config.extra.utterances.issue_term == "slug" %}
|
||||||
{% endif %}
|
data-issue-term="{{ page.slug }}"
|
||||||
data-lazy-loading="{{ config.extra.giscus.lazy_loading | default(value=true) }}">
|
{% else %}
|
||||||
|
data-issue-term="{{ config.extra.utterances.issue_term }}"
|
||||||
{% if config.extra.giscus.automatic_loading %}
|
{% endif %}
|
||||||
<script src="{{ get_url(path='js/giscus_min.js', trailing_slash=false) | safe }}" async></script>
|
data-label="{{ config.extra.utterances.label }}"
|
||||||
{% else %}
|
data-light-theme="{{ config.extra.utterances.light_theme }}"
|
||||||
<button id="load-comments" class="load-comments-button" data-script-src="{{ get_url(path='js/giscus_min.js', trailing_slash=false) | safe }}">{%- if lang != config.default_language %} {{ trans(key="load_comments" | safe, lang=lang) }}{% else %} Load comments {%- endif -%}</button>
|
data-dark-theme="{{ config.extra.utterances.dark_theme }}"
|
||||||
<script src="{{ get_url(path='js/loadComments_min.js', trailing_slash=false) | safe }}" async></script>
|
data-lazy-loading="{{ config.extra.utterances.lazy_loading | default(value=true) }}">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% elif utterances_enabled %}
|
|
||||||
<div class="comments centered-text"
|
|
||||||
{# 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 }}"
|
|
||||||
{% 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 | default(value=true) }}">
|
|
||||||
|
|
||||||
{% if config.extra.utterances.automatic_loading %}
|
|
||||||
<script src="{{ get_url(path='js/utterances_min.js', trailing_slash=false) | safe }}" async></script>
|
|
||||||
{% else %}
|
|
||||||
<button id="load-comments" class="load-comments-button" data-script-src="{{ get_url(path='js/utterances_min.js', trailing_slash=false) | safe }}">{%- if lang != config.default_language %} {{ trans(key="load_comments" | safe, lang=lang) }}{% else %} Load comments {%- endif -%}</button>
|
|
||||||
<script src="{{ get_url(path='js/loadComments_min.js', trailing_slash=false) | safe }}" async></script>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
{% 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 }}">...</button>
|
||||||
|
<script src="{{ get_url(path='js/loadComments_min.js', trailing_slash=false) | safe }}" async></script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{%- endmacro add_comments -%}
|
{%- endmacro add_comments -%}
|
||||||
|
Loading…
Reference in New Issue