diff --git a/src/router.ts b/src/router.ts index 7af5f44..724c753 100644 --- a/src/router.ts +++ b/src/router.ts @@ -14,7 +14,18 @@ const router = new Router({ { path: "/p", component: Single }, { path: "/p/:y/:mo/:name", component: Single }, { path: "/about", component: About } - ] + ], + scrollBehavior(to, from, savedPosition) { + if (savedPosition) { + return savedPosition; + } else if (to.hash) { + return { + selector: to.hash + }; + } else { + return { x: 0, y: 0 } + } + } }); document.addEventListener("click", (ev) => {