fix service worker

This commit is contained in:
Cadey Ratio 2018-10-20 13:34:44 -07:00
parent df2301f496
commit b749388104
3 changed files with 5 additions and 4 deletions

View File

@ -17,7 +17,7 @@ import (
"github.com/gorilla/feeds"
blackfriday "github.com/russross/blackfriday"
"github.com/tj/front"
"gopkg.in/segmentio/analytics-go.v3"
analytics "gopkg.in/segmentio/analytics-go.v3"
)
var port = os.Getenv("PORT")
@ -191,6 +191,9 @@ func Build() (*Site, error) {
s.mux.HandleFunc("/blog/", s.showPost)
s.mux.Handle("/css/", http.FileServer(http.Dir(".")))
s.mux.Handle("/static/", http.FileServer(http.Dir(".")))
s.mux.HandleFunc("/sw.js", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "./static/js/sw.js")
})
return s, nil
}

View File

@ -66,9 +66,7 @@
if (navigator.serviceWorker.controller) {
console.log("Active service worker found, no need to register");
} else {
navigator.serviceWorker.register("/static/js/pwabuilder-sw.js", {
scope: "https://christine.website/"
}).then(function(reg) {
navigator.serviceWorker.register("/sw.js").then(function(reg) {
console.log("Service worker has been registered for scope:" + reg.scope);
});
}