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:
parent
3be5a58a7c
commit
4e4acdbb6b
7 changed files with 371 additions and 70 deletions
|
@ -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">
|
||||
|
|
|
@ -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">
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue