aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assets/sw-register.js2
-rw-r--r--assets/sw.js4
2 files changed, 4 insertions, 2 deletions
diff --git a/assets/sw-register.js b/assets/sw-register.js
index 0b71f03..b67dbfd 100644
--- a/assets/sw-register.js
+++ b/assets/sw-register.js
@@ -1,4 +1,4 @@
-{{ $swJS := resources.Get "sw.js" | resources.ExecuteAsTemplate "sw.js" . }}
+{{- $swJS := resources.Get "sw.js" | resources.ExecuteAsTemplate "sw.js" . -}}
if (navigator.serviceWorker) {
navigator.serviceWorker.register(
"{{ $swJS.RelPermalink }}",
diff --git a/assets/sw.js b/assets/sw.js
index 0e7b0cf..2ff11fc 100644
--- a/assets/sw.js
+++ b/assets/sw.js
@@ -1,8 +1,10 @@
const cacheName = self.location.pathname
const pages = [
+{{ if eq .Site.Params.BookServiceWorker "precache" }}
{{ range .Site.AllPages -}}
"{{ .RelPermalink }}",
- {{ end }}
+ {{ end -}}
+{{ end }}
];
self.addEventListener("install", function (event) {