mirror of
https://github.com/alanorth/hugo-theme-bootstrap4-blog.git
synced 2025-05-09 14:06:02 +02:00
Use haven for GDPR popup instead of cookieconsent
Haven is newer and more well maintained (and also it is actually open source instead of open core with an upsell to a paid subscrip- tion). Haven is configured to be 100% *opt-in* for Google Analytics, which means it does not load or send a hit until the user agrees. This is mostly a drop-in replacement, but translations need to make sure the following strings are updated: - cookieAccept - cookieDecline
This commit is contained in:
@ -1,28 +1,38 @@
|
||||
{{ $cookieConsentStyle := resources.Get "css/cookieconsent.min.css" | resources.Fingerprint }}
|
||||
<link href="{{ $cookieConsentStyle.Permalink }}" rel="stylesheet" type="text/css"{{ if not .Site.Params.disable_sri }} integrity="{{ $cookieConsentStyle.Data.Integrity }}" crossorigin="anonymous"{{ end }}>
|
||||
{{ $cookieConsentScript := resources.Get "js/cookieconsent.min.js" | resources.Fingerprint }}
|
||||
<script src="{{ $cookieConsentScript.Permalink }}"{{ if not .Site.Params.disable_sri }} integrity="{{ $cookieConsentScript.Data.Integrity }}" crossorigin="anonymous"{{ end }} async></script>
|
||||
{{ $cookieConsentScript := resources.Get "js/haven.umd.min.js" | resources.Fingerprint }}
|
||||
<script src="{{ $cookieConsentScript.Permalink }}"{{ if not .Site.Params.disable_sri }} integrity="{{ $cookieConsentScript.Data.Integrity }}" crossorigin="anonymous"{{ end }}></script>
|
||||
|
||||
<script>
|
||||
window.addEventListener("load", function(){
|
||||
window.cookieconsent.initialise({
|
||||
"palette": {
|
||||
"popup": {
|
||||
"background": "#428bca",
|
||||
"text": "#ffffff"
|
||||
},
|
||||
"button": {
|
||||
"background": "#f71559"
|
||||
}
|
||||
Haven.create({
|
||||
notification: {
|
||||
policyUrl: "{{ .Site.Params.cookie_consent_info_url | absURL }}",
|
||||
styles: {
|
||||
background: '#428bca',
|
||||
textColor: '#ffffff',
|
||||
buttonBackgroundColor: '#f71559',
|
||||
buttonTextColor: '#ffffff',
|
||||
},
|
||||
},
|
||||
"content": {
|
||||
"message": '{{ i18n "cookieMessage" }}',
|
||||
"dismiss": '{{ i18n "cookieDismiss" }}',
|
||||
"link": '{{ i18n "cookieLink" }}',
|
||||
"href": "{{ .Site.Params.cookie_consent_info_url | absURL}}"
|
||||
translations: {
|
||||
{{ .Lang }}: {
|
||||
notification: {
|
||||
policy: '{{ i18n "cookieLink" }}',
|
||||
message: '{{ i18n "cookieMessage" }}',
|
||||
accept: '{{ i18n "cookieAccept" }}',
|
||||
decline: '{{ i18n "cookieDecline" }}',
|
||||
}
|
||||
},
|
||||
},
|
||||
"position": "bottom-right"
|
||||
})});
|
||||
services: [
|
||||
{
|
||||
name: 'google-analytics',
|
||||
options: {
|
||||
id: '{{ .Site.Params.googleAnalytics }}',
|
||||
},
|
||||
purposes: ['analytics'],
|
||||
inject: true,
|
||||
}
|
||||
]
|
||||
});
|
||||
</script>
|
||||
|
||||
{{- /* vim: set ts=2 sw=2 et: */}}
|
||||
|
Reference in New Issue
Block a user