From 554cb7ca387c9525e900b1e905175fbd527bf32b Mon Sep 17 00:00:00 2001 From: BeardedTek Date: Mon, 21 Apr 2025 22:51:03 -0800 Subject: [PATCH] Add Plausible Banner --- layouts/_default/baseof.html | 1 + layouts/partials/cookies/plausible.html | 21 +++++++++++++++++++++ layouts/partials/scripts.html | 2 +- static/js/plausible-exclude.js | 22 ++++++++++++++++++++++ 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 layouts/partials/cookies/plausible.html create mode 100644 static/js/plausible-exclude.js diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 5bd3aa0..ed6291f 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -16,6 +16,7 @@ {{ if ( .Site.Params.footer.enable ) }} {{ partial "footer/main" . }} {{ end }} + {{ partial "cookies/plausible" . }} {{ partial "scripts" . }} \ No newline at end of file diff --git a/layouts/partials/cookies/plausible.html b/layouts/partials/cookies/plausible.html new file mode 100644 index 0000000..e404a0b --- /dev/null +++ b/layouts/partials/cookies/plausible.html @@ -0,0 +1,21 @@ + + + \ No newline at end of file diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html index a94ee68..f7a9d6a 100644 --- a/layouts/partials/scripts.html +++ b/layouts/partials/scripts.html @@ -2,4 +2,4 @@ - + diff --git a/static/js/plausible-exclude.js b/static/js/plausible-exclude.js new file mode 100644 index 0000000..e417d0e --- /dev/null +++ b/static/js/plausible-exclude.js @@ -0,0 +1,22 @@ +// Plausible Exclude +const plausibleBanner = document.getElementById('plausible-banner'); +var hidePlausibleBanner = window.localStorage.getItem('hidePlausibleBanner'); + +function disablePlausible(e) { + window.localStorage.setItem('plausible_ignore', 'true'); + window.localStorage.setItem('hidePlausibleBanner','true'); + plausibleBanner.classList.add('hidden'); +} + +function enablePlausible(e) { + window.localStorage.removeItem('plausible_ignore'); + window.localStorage.setItem('hidePlausibleBanner','true'); + plausibleBanner.classList.add('hidden'); +} + + +if ( hidePlausibleBanner){ + plausibleBanner.classList.add('hidden'); +} else { + plausibleBanner.classList.remove('hidden'); +} \ No newline at end of file