* feat: add GDPR cookie consent banner
Add a GDPR-compliant cookie consent banner that gates analytics (Google
Analytics) and functional cookies (comments) until user consent is given.
Features:
- Theme-consistent styling using CSS variables (light/dark mode)
- Settings panel with category toggles (necessary, analytics, functional)
- Consent stored in cookie for 365 days
- Google Analytics only loads after analytics consent
- Comments only load after functional consent
- Translations for all 32 supported languages
- Accessible with proper ARIA attributes and focus management
Configuration in hugo.yaml:
params:
cookies:
enabled: true
categories:
analytics: true
functional: true
When cookies.enabled is false, scripts load normally without consent gating.
Closes #412
* refactor: move consent-gated GA to cookies/analytics.html
Move Google Analytics consent logic to avoid shadowing Hugo's internal
`_internal/google_analytics.html` template.
Changes:
- Rename google_analytics.html → cookies/analytics.html
- Update head.html to conditionally load:
- cookies.enabled=true: cookies/analytics.html (consent-gated)
- cookies.enabled=false: Hugo's _internal/google_analytics.html
- Align cookies/analytics.html with Hugo's internal template:
- Support Privacy.GoogleAnalytics.Disable setting
- Support Privacy.GoogleAnalytics.RespectDoNotTrack setting
- Add UA- prefix deprecation warning
Note: Custom JS is required for consent-gated GA because Hugo templates
render at build time, but consent happens at runtime. We cannot call
Hugo's internal template after the user grants consent - we must
dynamically inject the GA script via JavaScript.
* style: indent cookies/analytics.html
* refactor: don't use default, put default configurations in params.toml
* fix: don't use `description` as translation key because it's reserved and will throw error
* fix: remove footer/components/custom-font.html call
* fix: banner showSettings key
* style: indent comments/include
* Add missing article.alert translation back
* style: format i18n toml files
* style: indent head/head.html
* style adjustment
* style: add missing -
* style: format demo/config/params.toml
* style: remove redundant comments from cookies.scss
* style: update box-shadow for cookie banner content
---------
Co-authored-by: delize <4028612+delize@users.noreply.github.com>
Co-authored-by: Jimmy Cai <jimmy@cai.im>
80 lines
3.0 KiB
TOML
80 lines
3.0 KiB
TOML
toggleMenu = "Показати меню"
|
|
darkMode = "Темна тема"
|
|
|
|
[list]
|
|
section = "Секція"
|
|
|
|
[list.page]
|
|
one = "{{ .Count }} сторінка"
|
|
few = "{{ .Count }} сторінки"
|
|
other = "{{ .Count }} сторінок"
|
|
|
|
[list.subsection]
|
|
one = "Підсекція"
|
|
other = "Підсекції"
|
|
|
|
[article]
|
|
back = "Назад"
|
|
tableOfContents = "Зміст"
|
|
relatedContent = "Схожі матеріали"
|
|
lastUpdatedOn = "Востаннє оновлено"
|
|
|
|
[article.readingTime]
|
|
one = "Час читання: {{ .Count }} хв"
|
|
other = "Час читання: {{ .Count }} хв"
|
|
|
|
[article.alert]
|
|
note = "Примітка"
|
|
tip = "Порада"
|
|
important = "Важливо"
|
|
warning = "Попередження"
|
|
caution = "Обережно"
|
|
|
|
[notFound]
|
|
title = "Не знайдено"
|
|
subtitle = "Ця сторінка не існує"
|
|
|
|
[widget]
|
|
[widget.archives]
|
|
title = "Архіви"
|
|
more = "Більше"
|
|
|
|
[widget.tagCloud]
|
|
title = "Теґи"
|
|
|
|
[widget.categoriesCloud]
|
|
title = "Категорії"
|
|
|
|
[search]
|
|
title = "Пошук"
|
|
placeholder = "Напишіть що-небудь..."
|
|
resultTitle = "#PAGES_COUNT сторінок (#TIME_SECONDS секунд)"
|
|
|
|
[footer]
|
|
builtWith = "Створено з {{ .Generator }}"
|
|
designedBy = "Тема {{ .Theme }}, дизайн {{ .DesignedBy }}"
|
|
|
|
[cookies]
|
|
title = "Згода на використання файлів cookie"
|
|
text = "Ми використовуємо файли cookie для покращення вашого досвіду перегляду та аналізу трафіку сайту."
|
|
acceptAll = "Прийняти все"
|
|
deny = "Відхилити"
|
|
managePreferences = "Керувати налаштуваннями"
|
|
settingsTitle = "Налаштування файлів cookie"
|
|
savePreferences = "Зберегти налаштування"
|
|
cancel = "Скасувати"
|
|
footerLink = "Налаштування файлів cookie"
|
|
commentsDisabled = "Коментарі вимкнено, доки ви не приймете функціональні файли cookie."
|
|
|
|
[cookies.necessary]
|
|
title = "Необхідні"
|
|
text = "Ці файли cookie необхідні для роботи сайту і не можуть бути вимкнені."
|
|
|
|
[cookies.analytics]
|
|
title = "Аналітика"
|
|
text = "Ці файли cookie допомагають нам зрозуміти, як відвідувачі взаємодіють з нашим сайтом."
|
|
|
|
[cookies.functional]
|
|
title = "Функціональні"
|
|
text = "Ці файли cookie вмикають такі функції, як коментарі та вбудований контент."
|