diff options
author | Alex Shpak <alex-shpak@users.noreply.github.com> | 2020-05-01 17:45:23 +0200 |
---|---|---|
committer | Alex Shpak <alex-shpak@users.noreply.github.com> | 2020-05-01 17:45:23 +0200 |
commit | a877c17dc1ea541a54e46e3c3214e4d96b70e6cc (patch) | |
tree | 166ce13676ef0017896a68ec9022d4e2497918a8 /assets | |
parent | e2ffa7b3ad920d577cc56fbaaea12a99be125774 (diff) |
Add precache to service worker
Diffstat (limited to 'assets')
-rw-r--r-- | assets/sw-register.js | 2 | ||||
-rw-r--r-- | assets/sw.js | 4 |
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) { |