Add precache to service worker
This commit is contained in:
parent
e2ffa7b3ad
commit
a877c17dc1
2 changed files with 4 additions and 2 deletions
|
@ -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) {
|
if (navigator.serviceWorker) {
|
||||||
navigator.serviceWorker.register(
|
navigator.serviceWorker.register(
|
||||||
"{{ $swJS.RelPermalink }}",
|
"{{ $swJS.RelPermalink }}",
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
const cacheName = self.location.pathname
|
const cacheName = self.location.pathname
|
||||||
const pages = [
|
const pages = [
|
||||||
|
{{ if eq .Site.Params.BookServiceWorker "precache" }}
|
||||||
{{ range .Site.AllPages -}}
|
{{ range .Site.AllPages -}}
|
||||||
"{{ .RelPermalink }}",
|
"{{ .RelPermalink }}",
|
||||||
{{ end }}
|
{{ end -}}
|
||||||
|
{{ end }}
|
||||||
];
|
];
|
||||||
|
|
||||||
self.addEventListener("install", function (event) {
|
self.addEventListener("install", function (event) {
|
||||||
|
|
Loading…
Reference in a new issue