feat: add support for Hyvor Talk comments

This commit is contained in:
welpo
2023-07-17 20:10:18 +02:00
parent 5214dd3560
commit 7924e8206c
10 changed files with 184 additions and 43 deletions

View File

@@ -72,20 +72,27 @@
content="default-src 'self'
{%- 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 hyvortalk_enabled = config.extra.hyvortalk.enabled_for_all_posts or page.extra.hyvortalk %}
{% if hyvortalk_enabled %}
connect-src talk.hyvor.com;
{% endif %}
{%- for domain in config.extra.allowed_domains -%}
{{ domain.directive }} {{ domain.domains | join(sep=' ') -}}
{% if utterances_enabled -%}
{% if utterances_enabled or hyvortalk_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" -%}
{%- 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
{%- if giscus_enabled %} giscus.app
{%- elif utterances_enabled %} utteranc.es
{%- elif hyvortalk_enabled %} talk.hyvor.com
{%- endif %}
{%- endif -%}
{%- if not loop.last -%}