* 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>
79 lines
3.1 KiB
TOML
79 lines
3.1 KiB
TOML
toggleMenu = "Покажи Меню"
|
||
darkMode = "Тъмен Режим"
|
||
|
||
[list]
|
||
section = "Секция"
|
||
|
||
[list.page]
|
||
one = "{{ .Count }} страница"
|
||
other = "{{ .Count }} страници"
|
||
|
||
[list.subsection]
|
||
one = "Подсекция"
|
||
other = "Подсекции"
|
||
|
||
[article]
|
||
back = "Назад"
|
||
tableOfContents = "Съдържание"
|
||
relatedContent = "Свързано Съдържание"
|
||
lastUpdatedOn = "Последна промяна на"
|
||
|
||
[article.readingTime]
|
||
one = "{{ .Count }} minute read"
|
||
other = "{{ .Count }} minute read"
|
||
|
||
[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 = "Съгласие за бисквитки"
|
||
text = "Използваме бисквитки, за да подобрим вашето изживяване и да анализираме трафика на сайта."
|
||
acceptAll = "Приемане на всички"
|
||
deny = "Откажи"
|
||
managePreferences = "Управление на предпочитанията"
|
||
settingsTitle = "Предпочитания за бисквитки"
|
||
savePreferences = "Запазване на предпочитанията"
|
||
cancel = "Отказ"
|
||
footerLink = "Настройки на бисквитките"
|
||
commentsDisabled = "Коментарите са деактивирани, докато не приемете функционални бисквитки."
|
||
|
||
[cookies.necessary]
|
||
title = "Необходими"
|
||
text = "Тези бисквитки са необходими за функционирането на уебсайта и не могат да бъдат деактивирани."
|
||
|
||
[cookies.analytics]
|
||
title = "Анализи"
|
||
text = "Тези бисквитки ни помагат да разберем как посетителите взаимодействат с нашия уебсайт."
|
||
|
||
[cookies.functional]
|
||
title = "Функционални"
|
||
text = "Тези бисквитки активират функции като коментари и вградено съдържание."
|