diff options
| author | Reorx <novoreorx@gmail.com> | 2022-04-11 15:31:36 +0800 |
|---|---|---|
| committer | Reorx <novoreorx@gmail.com> | 2022-04-11 15:40:04 +0800 |
| commit | b9bc8b7d3b94aa90c3c7d8137709cb1154df51ba (patch) | |
| tree | d9e3f25acbf7ee72886e5de19f75ffcb648feb7f /layouts | |
| parent | 8c37662b321192b73744d35a3138b5365956b933 (diff) | |
replace instantpage with instantclick
Diffstat (limited to 'layouts')
| -rw-r--r-- | layouts/partials/footer.html | 13 | ||||
| -rw-r--r-- | layouts/partials/head.html | 8 |
2 files changed, 12 insertions, 9 deletions
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index e00d242..4e348be 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -34,7 +34,9 @@ } const disableSmoothScroll = '{{- if (.Param "DisableSmoothScroll") -}}1{{- end -}}' == '1'; - if (window.matchMedia('(prefers-reduced-motion: reduce)').matches || disableSmoothScroll) { + const enableInstantClick = '{{- if (.Param "EnableInstantClick") -}}1{{- end -}}' == '1'; + // instant click and smooth scroll are mutually exclusive + if (window.matchMedia('(prefers-reduced-motion: reduce)').matches || disableSmoothScroll || enableInstantClick) { return; } // only run this code if smooth scroll should be enabled @@ -191,3 +193,12 @@ window.addEventListener('DOMContentLoaded', function (event) { }, false); </script> {{- end }} + +{{- /* InstantClick.js */}} +{{- if (.Param "EnableInstantClick") }} +{{- $instantclick := slice (resources.Get "js/instantclick.js") | resources.Concat "assets/js/instantclick.js" | minify }} +<script src="{{ $instantclick.RelPermalink }}" data-no-instant + {{- if site.Params.assets.disableFingerprinting }}integrity="{{ $instantclick.Data.Integrity }}"{{- end }} +></script> +<script data-no-instant>InstantClick.init();</script> +{{- end }} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index ecce55c..b921452 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -151,11 +151,3 @@ {{- template "partials/templates/twitter_cards.html" . }} {{- template "partials/templates/schema_json.html" . }} {{- end -}} - -{{- /* InstantPage.js */}} -{{- if (.Param "EnableInstantPage") }} -{{- $instantpage := slice (resources.Get "js/instantpage.js") | resources.Concat "assets/js/instantpage.js" | minify }} -<script defer crossorigin="anonymous" src="{{ $instantpage.RelPermalink }}" type="module" - {{- if site.Params.assets.disableFingerprinting }}integrity="{{ $instantpage.Data.Integrity }}"{{- end }} -></script> -{{- end }} |
