summaryrefslogtreecommitdiff
path: root/layouts
diff options
context:
space:
mode:
authorReorx <novoreorx@gmail.com>2022-05-28 02:10:33 +0800
committerReorx <novoreorx@gmail.com>2022-05-28 02:10:33 +0800
commitc60eaeb53510978427107bfa0f758e37094d0da9 (patch)
treeffc15d16e22476fb943d20bc7b36fae9ac282304 /layouts
parent0d1dec9d55f27dbed27236bd3750011d7a1539e8 (diff)
instantclick: support updating head tags
only for meta and link (not stylesheet) tags
Diffstat (limited to 'layouts')
-rw-r--r--layouts/partials/footer.html3
-rw-r--r--layouts/partials/header.html3
2 files changed, 5 insertions, 1 deletions
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html
index a38931d..2f7f3e2 100644
--- a/layouts/partials/footer.html
+++ b/layouts/partials/footer.html
@@ -147,6 +147,9 @@
{{- /* InstantClick.js */}}
{{- if (.Param "EnableInstantClick") }}
{{- $instantclick := resources.Get "js/instantclick.js" }}
+{{- if hugo.IsProduction }}
+ {{- $instantclick = minify $instantclick }}
+{{- end }}
<script src="{{ $instantclick.RelPermalink }}" data-no-instant
{{- if site.Params.assets.disableFingerprinting }}integrity="{{ $instantclick.Data.Integrity }}"{{- end }}
></script>
diff --git a/layouts/partials/header.html b/layouts/partials/header.html
index 166eee1..0ed0b20 100644
--- a/layouts/partials/header.html
+++ b/layouts/partials/header.html
@@ -30,7 +30,7 @@ function setPrefTheme(theme) {
const toggleThemeCallbacks = []
toggleThemeCallbacks.push((isDark) => {
- // console.log('window toggle-theme')
+ // console.log('window toggle-theme 1')
if (isDark) {
setPrefTheme('light');
} else {
@@ -42,6 +42,7 @@ toggleThemeCallbacks.push((isDark) => {
// because window is never changed by InstantClick,
// we add the listener to window to ensure the event is always received
window.addEventListener('toggle-theme', function() {
+ // console.log('window toggle-theme')
const isDark = isDarkTheme()
toggleThemeCallbacks.forEach(callback => callback(isDark))
});