hugo-bearblog : combine darkmode script

This commit is contained in:
minoplhy 2024-03-14 03:26:50 +07:00
parent 1b7f3ec2dc
commit 2615349a7d
Signed by: minoplhy
GPG Key ID: 41D406044E2434BF

View File

@ -25,15 +25,6 @@
<link crossorigin="anonymous" href="{{ $stylesheet.RelPermalink }}" rel="preload stylesheet" as="style">
{{ end }}
{{- /* Javascript */}}
{{- $darkmode_script := (resources.Get "js/darkmode.js") | resources.Minify }}
{{- if not site.Params.assets.disableFingerprinting }}
{{- $darkmode_script := $darkmode_script | fingerprint }}
<script crossorigin="anonymous" src="{{ $darkmode_script.RelPermalink }}" integrity="{{ $darkmode_script.Data.Integrity }}"></script>
{{ else }}
<script crossorigin="anonymous" src="{{ $darkmode_script.RelPermalink }}"></script>
{{ end }}
<!-- A partial to be overwritten by the user.
Simply place a custom_head.html into
your local /layouts/partials-directory -->
@ -42,6 +33,17 @@
<body>
{{- /* Darkmode Javascript */}}
{{- $darkmode_script := (resources.Get "js/darkmode.js") }}
{{- $darkmode_load_script := (resources.Get "js/darkmode_load.js") }}
{{- $darkmode_combined := slice $darkmode_script $darkmode_load_script | resources.Concat "js/darkmode.js" | resources.Minify }}
{{- if not site.Params.assets.disableFingerprinting }}
{{- $darkmode_combined := $darkmode_combined | fingerprint }}
<script crossorigin="anonymous" src="{{ $darkmode_combined.RelPermalink }}" integrity="{{ $darkmode_combined.Data.Integrity }}"></script>
{{ else }}
<script crossorigin="anonymous" src="{{ $darkmode_combined.RelPermalink }}"></script>
{{ end }}
<header>
{{- partial "header.html" . -}}
</header>
@ -57,15 +59,6 @@
{{- partial "custom_footer.html" -}}
</footer>
{{- /* Bottom Javascript */}}
{{- $darkmode_load_script := (resources.Get "js/darkmode_load.js") | resources.Minify}}
{{- if not site.Params.assets.disableFingerprinting }}
{{- $darkmode_load_script := $darkmode_load_script | fingerprint }}
<script crossorigin="anonymous" src="{{ $darkmode_load_script.RelPermalink }}" integrity="{{ $darkmode_load_script.Data.Integrity }}"></script>
{{ else }}
<script crossorigin="anonymous" src="{{ $darkmode_load_script.RelPermalink }}"></script>
{{ end }}
<!-- A partial to be overwritten by the user.
Simply place a custom_body.html into
your local /layouts/partials-directory -->