From 43cb271077a6a7ac76667a0d433e74afc798123c Mon Sep 17 00:00:00 2001 From: Lorenzo Iovino Date: Tue, 29 Sep 2026 00:36:29 +0200 Subject: [PATCH] fix: show the dark mode toast only after the cookie banner is answered --- src/layouts/BaseLayout.astro | 45 ++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index 28b8a59..71dcc63 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -69,6 +69,20 @@ const fullCanonicalUrl = canonicalUrl || `${siteUrl}${Astro.url.pathname}`; showTitle: false, textColor: "#000000", }, + // Let the dark mode toast wait until the cookie banner is gone + callback: { + onBannerShown: function () { + window.__iubBannerOpen = true; + }, + onPreferenceExpressed: function () { + window.__iubBannerOpen = false; + window.dispatchEvent(new Event("iub-consent")); + }, + onReady: function () { + window.__iubReady = true; + window.dispatchEvent(new Event("iub-ready")); + }, + }, };