From 88a86b67c0e4e423bdf5bba01643346f7492991d Mon Sep 17 00:00:00 2001 From: "Chris K.Y. FUNG" <8746768+chriskyfung@users.noreply.github.com> Date: Tue, 12 Mar 2024 01:44:38 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=91=20fix(amp):=20remove=20`data-ampde?= =?UTF-8?q?vmode`=20on=20non-dev=20environment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit removes the `data-ampdevmode` attribute from the `` component in non-development environments. This attribute is used to enable development-specific features, such as the ability to load scripts from a local server. However, it can also lead to unintended behavior in production environments, such as preventing scripts from running or causing validation errors. By removing this attribute in non-development environments, we ensure that AMP pages are always served with the correct configuration and that scripts are executed as intended. To address this issue, this commit adds two new options to the site configuration: - `amp_optimizer`: Set true if you run AMP Optimizer after building the Jekyll site. Defaults to false. - `script_hash`: A hash for the get_stored_consentStates script. Defaults to empty. Fixes #58 See also #44 --- _config.yml | 3 +++ _includes/consent/granular-user-consent.html | 7 +++---- _layouts/default.html | 3 +++ _posts/2021-08-02-config-guide.md | 18 +++++++++++++----- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/_config.yml b/_config.yml index 13c9b0d8..3926a043 100644 --- a/_config.yml +++ b/_config.yml @@ -92,6 +92,9 @@ copyright: # Cookie Consent Notice consent: true consent_dev_mode: false +amp_optimizer: true +script_hash: + consent_gsc: sha384-n2-YMnb2FkeDk-Ca2pVnoYSR2FqNKqKgTwfK_UI0EAeVRCAHgCDjsecHJpVMv3Sl # Plugins plugins: diff --git a/_includes/consent/granular-user-consent.html b/_includes/consent/granular-user-consent.html index c024690d..fc643747 100644 --- a/_includes/consent/granular-user-consent.html +++ b/_includes/consent/granular-user-consent.html @@ -12,12 +12,11 @@ -{%- if jekyll.environment == 'production' and site.consent_dev_mode == false -%} - +{%- if jekyll.environment == 'production' or site.consent_dev_mode == false -%} + {%- else -%} - + {%- endif -%} -