feat: add support for giscus & utterances comments

This commit is contained in:
welpo
2023-07-12 18:44:28 +02:00
parent 93c8b577b8
commit 19d120019b
17 changed files with 333 additions and 99 deletions

View File

@@ -14,7 +14,7 @@
<link rel=icon href='data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg" viewBox="0 0 105 55"><text y=".7em" font-size="90">{{ config.extra.favicon_emoji }}</text></svg>'>
{% endif %}
{# RSS #}
{# Feed #}
<link rel="alternate" type="application/atom+xml" title="{{ config.title }}" href="{{ get_url(path="atom.xml",
trailing_slash=false) }}">
@@ -36,7 +36,16 @@
{% endfor %}
{% endif %}
<meta name="description" content="{{ config.description }}">
<meta name="color-scheme" content="light dark">
{%- if page.description %}
<meta name="description" content="{{ page.description }}" />
{%- elif page.summary %}
<meta name="description" content="{{ page.summary }}" />
{%- else %}
<meta name="description" content="{{ config.description }}" />
{%- endif %}
{% if is_404 %}
<meta name="robots" content="noindex, follow">
{% else %}
@@ -61,11 +70,18 @@
content="default-src 'self'
{%- if config.extra.allowed_domains -%}
;
{%- 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 -%}
{%- for domain in config.extra.allowed_domains -%}
{{ domain.directive }} {{ domain.domains | join(sep=' ') }}
{{ domain.directive }} {{ domain.domains | join(sep=' ') -}}
{% if utterances_enabled -%}
{%- if domain.directive == "style-src" %} 'unsafe-inline'
{%- endif -%}
{% endif -%}
{# Automatically allow giscus/utterances, if enabled #}
{%- if domain.directive == "script-src" or domain.directive == "frame-src" or domain.directive == "style-src" -%}
{%- if domain.directive == "script-src" or domain.directive == "frame-src" -%}
{%- if config.extra.giscus.enabled_for_all_posts or page.extra.giscus %} giscus.app
{%- elif config.extra.utterances.enabled_for_all_posts or page.extra.utterances%} utteranc.es
{%- endif %}
@@ -77,8 +93,8 @@
{%- endif -%}">
{%- if config.extra.theme_switcher and config.extra.theme_switcher == true -%}
<script type="text/javascript" src="{{ get_url(path='js/initialize_theme_min.js') | safe }}"></script>
<script defer src="{{ get_url(path='js/main_min.js', trailing_slash=false) | safe }}"/></script>
<script type="text/javascript" src="{{ get_url(path='js/initializeTheme_min.js') | safe }}"></script>
<script defer src="{{ get_url(path='js/themeSwitcher_min.js', trailing_slash=false) | safe }}"/></script>
{%- endif -%}
</head>