Compare commits
4 Commits
b33546eb26
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 386ae49027 | |||
| d534cc2f05 | |||
| b0793486eb | |||
| 2bae3b820c |
12
Makefile
Normal file
12
Makefile
Normal file
@@ -0,0 +1,12 @@
|
||||
BUILD_DIR := public
|
||||
|
||||
.PHONEY: serve build clean
|
||||
|
||||
serve:
|
||||
hugo server -D
|
||||
|
||||
build:
|
||||
hugo --minify
|
||||
|
||||
clean:
|
||||
rm -r $(BUILD_DIR)
|
||||
40
assets/css/consent.css
Normal file
40
assets/css/consent.css
Normal file
@@ -0,0 +1,40 @@
|
||||
/* Banner container - default (desktop) */
|
||||
#cookie-consent-banner {
|
||||
display: none;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background: #333;
|
||||
padding: 1rem;
|
||||
text-align: center;
|
||||
z-index: 9999;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.cookie-buttons {
|
||||
margin-top: 0.75rem;
|
||||
}
|
||||
|
||||
/* Mobile styles */
|
||||
@media screen and (max-width: 768px) {
|
||||
#cookie-consent-banner {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
text-align: left;
|
||||
padding: 0.75px;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
#cookie-consent-banner .cookie-text {
|
||||
max-width: 70%;
|
||||
}
|
||||
|
||||
.cookie-buttons {
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
54
layouts/partials/extended_head.html
Normal file
54
layouts/partials/extended_head.html
Normal file
@@ -0,0 +1,54 @@
|
||||
<!-- Cookie Consent Banner -->
|
||||
<div id="cookie-consent-banner" style="display:none;">
|
||||
<div class="cookie-text">
|
||||
We use cookies and analytics to improve your experience.
|
||||
</div>
|
||||
<div class="cookie-buttons">
|
||||
<button id="accept-cookies">Accept</button>
|
||||
<button id="reject-cookies">Reject</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
const banner = document.getElementById('cookie-consent-banner');
|
||||
const accepted = localStorage.getItem('cookies-accepted');
|
||||
|
||||
// Show banner if no decision yet
|
||||
if (!accepted) {
|
||||
banner.style.display = 'block';
|
||||
} else if (accepted === 'true') {
|
||||
loadGoogleAnalytics();
|
||||
}
|
||||
|
||||
// Accept cookies
|
||||
document.getElementById('accept-cookies').addEventListener('click', function() {
|
||||
localStorage.setItem('cookies-accepted', 'true');
|
||||
banner.style.display = 'none';
|
||||
loadGoogleAnalytics();
|
||||
});
|
||||
|
||||
// Reject cookies
|
||||
document.getElementById('reject-cookies').addEventListener('click', function() {
|
||||
localStorage.setItem('cookies-accepted', 'false');
|
||||
banner.style.display = 'none';
|
||||
});
|
||||
});
|
||||
|
||||
// Function to load GA after consent
|
||||
function loadGoogleAnalytics() {
|
||||
if (!document.getElementById('ga-script')) {
|
||||
const script = document.createElement('script');
|
||||
script.id = 'ga-script';
|
||||
script.async = true;
|
||||
script.src = "https://www.googletagmanager.com/gtag/js?id=G-JFCYXHXCN1";
|
||||
document.head.appendChild(script);
|
||||
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'G-JFCYXHXCN1');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user