Set script in-line with integrity hash

Signed-off-by: Emruz Hossain <hossainemruz@gmail.com>
This commit is contained in:
Emruz Hossain 2024-11-30 06:10:45 +06:00
parent 56787e0963
commit 764a16effc
7 changed files with 363 additions and 61 deletions

View file

@ -17,17 +17,11 @@
<!--================= add analytics if enabled =========================-->
{{- partial "analytics.html" . -}}
<script>
theme = localStorage.getItem('theme-scheme') || localStorage.getItem('darkmode:color-scheme') || 'light';
if (theme == 'system') {
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
theme = 'dark';
} else {
theme = 'light';
}
}
document.documentElement.setAttribute('data-theme', theme);
{{ with resources.Get "scripts/core/theme-scheme.js" | fingerprint }}
<script integrity="{{.Data.Integrity}}">
{{ .Content | safeJS }}
</script>
{{ end }}
</head>
<body data-bs-spy="scroll" data-bs-target="#top-navbar" data-bs-offset="100">