@@ -50,7 +63,8 @@ prev(ev) { } if (self.pid > 1) { self.pid--; - self.setPost(self.pid); + route(`/${self.pid}`); + //self.setPost(self.pid); self.update(); } } @@ -63,12 +77,15 @@ next(ev) { self.nextloading = " loading"; if (!self.nomore) { self.pid++; - self.setPost(self.pid); + route(`/${self.pid}`); + //self.setPost(self.pid); self.update(); } } setPost(pid) { + console.log("in setPost"); + console.log(pid); this.update(); this.loading = true; fetch(`/blog/switchpost/${pid-1}`) @@ -92,14 +109,12 @@ setPost(pid) { self.title = "No more posts!"; self.nomore = true; self.update(); - route(`/${pid}`); return; } self.author = postcontent[0].doc.author[0]; self.content = postcontent[0].doc.content[0]; self.title = postcontent[0].doc.title[0]; self.update(); - route(`/${pid}`); } self.loading = false; @@ -108,8 +123,11 @@ setPost(pid) { self.update(); }); } - -this.on("mount", () => { this.setPost(self.pid) }); +this.on("mount", () => { + route("*", this.setPost); + console.log("starting the router"); + route.start(true); +}); diff --git a/src/templates/index.html b/src/templates/index.html index 955f9f2..fd0ec06 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -2,7 +2,7 @@