Remove in-line script from header (#1004)

* remove in-line script from header

* oops!

* Set script in-line with integrity hash

Signed-off-by: Emruz Hossain <hossainemruz@gmail.com>

---------

Signed-off-by: Emruz Hossain <hossainemruz@gmail.com>
Co-authored-by: Emruz Hossain <hossainemruz@gmail.com>
This commit is contained in:
David G. Simmons 2024-12-01 09:37:33 -05:00 committed by GitHub
parent 3be5a58a7c
commit 4e4acdbb6b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 371 additions and 70 deletions

View file

@ -11,17 +11,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 class="type-{{ .Page.Type }} kind-{{ .Page.Kind }}" data-bs-spy="scroll" data-bs-target="#TableOfContents" data-bs-offset="80">

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">