mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-13 18:15:09 +00:00
refactor: define cookie consent assets in assets.toml
Moved the Cookie Consent asset definition to assets.toml so that it's possible for offline site to use local Cookie Consent assets. Also upgraded Cookie Consent to 3.1.1. Close #1495
This commit is contained in:
1 parent
361707f4fd
commit
3965252fc5
2 files changed
+18
-6
No files matched your search
@@ -65,6 +65,10 @@
|
||||
sri = "sha256-Md1qLToewPeKjfAHU1zyPwOutccPAm5tahnaw7Osw0A="
|
||||
url = "https://cdnjs.cloudflare.com/ajax/libs/lazysizes/%s/lazysizes.min.js"
|
||||
async = true
|
||||
[js.cookieconsent]
|
||||
version = "3.1.1"
|
||||
sri = "sha256-5VhCqFam2Cn+yjw61zbBNrbHVJ6SRydPeKopYlngbiQ="
|
||||
url = "https://cdnjs.cloudflare.com/ajax/libs/cookieconsent2/%s/cookieconsent.min.js"
|
||||
|
||||
# CSS
|
||||
|
||||
@@ -96,3 +100,7 @@
|
||||
version = "9.15.10"
|
||||
sri = "" # No SRI as highlight style is determined at run time.
|
||||
url = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/%s/styles/%s.min.css"
|
||||
[css.cookieconsent]
|
||||
version = "3.1.1"
|
||||
sri = "sha256-zQ0LblD/Af8vOppw18+2anxsuaz3pWYyVWi+bTvTH8Q="
|
||||
url = "https://cdnjs.cloudflare.com/ajax/libs/cookieconsent2/%s/cookieconsent.min.css"
|
||||
@@ -1,8 +1,12 @@
|
||||
{{ if site.Params.privacy_pack }}
|
||||
{{ $scr := .Scratch }}
|
||||
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.js"></script>
|
||||
<script>
|
||||
{{ $scr := .Scratch }}
|
||||
{{ $js := site.Data.assets.js }}
|
||||
{{ $css := site.Data.assets.css }}
|
||||
{{ if ($scr.Get "use_cdn") }}
|
||||
{{ printf "<script src=\"%s\" integrity=\"%s\" crossorigin=\"anonymous\"></script>" (printf $js.cookieconsent.url $js.cookieconsent.version) $js.cookieconsent.sri | safeHTML }}
|
||||
{{ printf "<link rel=\"stylesheet\" href=\"%s\" integrity=\"%s\" crossorigin=\"anonymous\">" (printf $css.cookieconsent.url $css.cookieconsent.version) $css.cookieconsent.sri | safeHTML }}
|
||||
{{ end }}
|
||||
<script>
|
||||
window.addEventListener("load", function(){
|
||||
window.cookieconsent.initialise({
|
||||
"palette": {
|
||||
@@ -20,8 +24,8 @@
|
||||
"message": {{ i18n "cookie_message" | default "This website uses cookies to ensure you get the best experience on our website." }},
|
||||
"dismiss": {{ i18n "cookie_dismiss" | default "Got it!" }},
|
||||
"link": {{ i18n "cookie_learn" | default "Learn more" }},
|
||||
"href": {{ with site.GetPage "privacy.md" }}{{ printf "%s" .RelPermalink }}{{ else }}"https://cookies.insites.com"{{ end }}
|
||||
"href": {{ with site.GetPage "privacy.md" }}{{ printf "%s" .RelPermalink }}{{ else }}"https://www.cookiesandyou.com"{{ end }}
|
||||
}
|
||||
})});
|
||||
</script>
|
||||
</script>
|
||||
{{ end }}
|
||||
Reference in new issue
Block a user