diff --git a/docs.json b/docs.json index 3cb76e6..99ef6d7 100644 --- a/docs.json +++ b/docs.json @@ -36,6 +36,12 @@ "metadata": { "timestamp": true }, + "integrations": { + "cookies": { + "key": "kosli_consent", + "value": "accepted" + } + }, "favicon": "/favicon-32x32.png", "redirects": { "$ref": "./config/redirects.json" diff --git a/termly.js b/termly.js new file mode 100644 index 0000000..61892b9 --- /dev/null +++ b/termly.js @@ -0,0 +1,57 @@ +// Termly cookie consent banner + cross-subdomain consent sync from www.kosli.com. +// Mintlify auto-includes any .js file at the content root on every page, +// so this loads on every doc page on docs.kosli.com. +// +// Companion config: docs.json `integrations.cookies` gates Mintlify's own +// telemetry on the `kosli_consent` localStorage flag we set below. + +(function () { + if (window.__kosliTermlyLoaded) return; + window.__kosliTermlyLoaded = true; + + window.TERMLY_CUSTOM_BLOCKING_MAP = { + "kosli.com": "essential" + }; + + function syncConsent(data) { + if (data.categories && data.categories.includes("analytics")) { + localStorage.setItem("kosli_consent", "accepted"); + } else { + localStorage.removeItem("kosli_consent"); + } + } + + // Called when the Termly script finishes loading. + window.onTermlyLoaded = function () { + if (window.Termly && window.Termly.on) { + Termly.on("consent", syncConsent); + } + }; + + function init() { + if (!document.getElementById("kosli-termly-embed")) { + const s = document.createElement("script"); + s.id = "kosli-termly-embed"; + s.src = "https://app.termly.io/resource-blocker/c98bfcd6-2f30-4f3c-b53c-d6dbd9b8c40c?autoBlock=on"; + s.setAttribute("data-master-consents-origin", "https://www.kosli.com"); + s.setAttribute("onload", "onTermlyLoaded()"); + document.head.appendChild(s); + } + + if (!document.getElementById("kosli-consent-sync")) { + const f = document.createElement("iframe"); + f.id = "kosli-consent-sync"; + f.src = "https://www.kosli.com/consent-sync.html"; + f.title = "consent sync"; + f.setAttribute("aria-hidden", "true"); + f.style.display = "none"; + (document.body || document.documentElement).appendChild(f); + } + } + + if (document.readyState === "loading") { + document.addEventListener("DOMContentLoaded", init, { once: true }); + } else { + init(); + } +})();