From c7deb06b790fbf68034407c29bcf845641796198 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Tue, 20 Sep 2022 13:39:12 +0200 Subject: [PATCH] Fixed cookie consent when analytics was not set --- material/partials/consent.html | 14 +++++++++----- src/partials/consent.html | 16 ++++++++++------ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/material/partials/consent.html b/material/partials/consent.html index e909521e7..6156c60e9 100644 --- a/material/partials/consent.html +++ b/material/partials/consent.html @@ -1,12 +1,16 @@ {#- This file was automatically generated - do not edit -#} -{% set cookies = config.extra.consent.cookies %} -{% if config.extra.analytics and not cookies %} - {% set cookies = { "analytics": "Google Analytics" } %} +{% set cookies = config.extra.consent.cookies | d({}) %} +{% if config.extra.analytics %} + {% if "analytics" not in cookies %} + {% set _ = cookies.update({ "analytics": "Google Analytics" }) %} + {% endif %} {% endif %} -{% if "github.com" in config.repo_url and "github" not in cookies %} - {% set _ = cookies.update({ "github": "GitHub" }) %} +{% if "github.com" in config.repo_url %} + {% if "github" not in cookies %} + {% set _ = cookies.update({ "github": "GitHub" }) %} + {% endif %} {% endif %} {% set actions = config.extra.consent.actions %} {% if not actions %} diff --git a/src/partials/consent.html b/src/partials/consent.html index 4aad2e664..0fdad8278 100644 --- a/src/partials/consent.html +++ b/src/partials/consent.html @@ -20,13 +20,17 @@ IN THE SOFTWARE. --> - -{% set cookies = config.extra.consent.cookies %} -{% if config.extra.analytics and not cookies %} - {% set cookies = { "analytics": "Google Analytics" } %} + +{% set cookies = config.extra.consent.cookies | d({}) %} +{% if config.extra.analytics %} + {% if "analytics" not in cookies %} + {% set _ = cookies.update({ "analytics": "Google Analytics" }) %} + {% endif %} {% endif %} -{% if "github.com" in config.repo_url and "github" not in cookies %} - {% set _ = cookies.update({ "github": "GitHub" }) %} +{% if "github.com" in config.repo_url %} + {% if "github" not in cookies %} + {% set _ = cookies.update({ "github": "GitHub" }) %} + {% endif %} {% endif %}