mirror of
https://github.com/alanorth/hugo-theme-bootstrap4-blog.git
synced 2024-12-19 00:52:19 +01:00
Alan Orth
26f170bfdd
Previously we showed the Cookie Usage banner if the site's config had a cookie consent URL specified. As of 2018-05 (GDPR) it makes more sense to only display this banner if the site has a Google Analytics ID set. Because we are using Haven for consent manage- ment we can now inject Google Analytics automatically after the user has agreed, so we no longer need to use Hugo's internal te- mplate.
39 lines
1.2 KiB
HTML
39 lines
1.2 KiB
HTML
{{ $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>
|
|
Haven.create({
|
|
notification: {
|
|
policyUrl: "{{ .Site.Params.cookie_consent_info_url | absURL }}",
|
|
styles: {
|
|
background: '#428bca',
|
|
textColor: '#ffffff',
|
|
buttonBackgroundColor: '#f71559',
|
|
buttonTextColor: '#ffffff',
|
|
},
|
|
},
|
|
translations: {
|
|
{{ .Lang }}: {
|
|
notification: {
|
|
policy: '{{ i18n "cookieLink" }}',
|
|
message: '{{ i18n "cookieMessage" }}',
|
|
accept: '{{ i18n "cookieAccept" }}',
|
|
decline: '{{ i18n "cookieDecline" }}',
|
|
}
|
|
},
|
|
},
|
|
services: [
|
|
{
|
|
name: 'google-analytics',
|
|
options: {
|
|
id: {{ .Site.GoogleAnalytics }},
|
|
},
|
|
purposes: ['analytics'],
|
|
inject: true,
|
|
}
|
|
]
|
|
});
|
|
</script>
|
|
|
|
{{- /* vim: set ts=2 sw=2 et: */}}
|