From 355df550fc7bd95602af633e788907fca02578c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar?= Date: Sat, 9 Sep 2023 22:50:53 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20allow=20live=20reload=20w?= =?UTF-8?q?hen=20zola=20is=20in=20`serve`=20mode=20(#144)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/partials/header.html | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/templates/partials/header.html b/templates/partials/header.html index 656882e..b777dc6 100644 --- a/templates/partials/header.html +++ b/templates/partials/header.html @@ -105,13 +105,28 @@ {%- 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 -%} + {#- Initialise a base connect-src directive -#} + {%- set connect_src = "connect-src 'self'" -%} + {%- if hyvortalk_enabled -%} - connect-src talk.hyvor.com; + {%- set connect_src = connect_src ~ " talk.hyvor.com" -%} {%- elif isso_enabled -%} - connect-src {{ config.extra.isso.endpoint_url }}; + {%- set connect_src = connect_src ~ " " ~ config.extra.isso.endpoint_url -%} + {%- endif -%} + + {#- Append WebSocket for Zola serve mode -#} + {%- if config.mode == "serve" -%} + {%- set connect_src = connect_src ~ " ws:" -%} {%- endif -%} {%- for domain in config.extra.allowed_domains -%} + {%- if domain.directive == "connect-src" -%} + {%- set configured_connect_src = domain.domains | join(sep=' ') -%} + {%- set_global connect_src = connect_src ~ " " ~ configured_connect_src -%} + {%- continue -%} + {%- endif -%} + + {#- Handle directives that are not connect-src -#} {{ domain.directive }} {{ domain.domains | join(sep=' ') -}} {% if utterances_enabled or hyvortalk_enabled -%} @@ -134,6 +149,10 @@ ; {%- endif -%} {%- endfor -%} + + {#- Insert the generated connect-src -#} + {{ ";" ~ connect_src }} + {%- endif -%}"> {%- if config.extra.theme_switcher and config.extra.theme_switcher == true -%}