|
|
@@ -20,10 +20,21 @@ router.beforeEach((to, from, next) => {
|
|
20
|
20
|
document.title = `${document.title} - ${path}`
|
|
21
|
21
|
}
|
|
22
|
22
|
// Append slugs and sort titles
|
|
23
|
|
- if (to.path.split('/')[2])
|
|
|
23
|
+ if (to.path.split('/')[2]) {
|
|
24
|
24
|
document.title = `${document.title} - ${to.path.split('/')[2]}`
|
|
|
25
|
+ }
|
|
25
|
26
|
|
|
26
|
|
- next()
|
|
|
27
|
+ // Jump link intercept
|
|
|
28
|
+ if (to.hash) {
|
|
|
29
|
+ console.log('jump to:', to.hash)
|
|
|
30
|
+ const el = document.querySelector(to.hash)
|
|
|
31
|
+ const barHeight = 50
|
|
|
32
|
+ window.scrollTo(0, el.offsetTop - barHeight)
|
|
|
33
|
+ }
|
|
|
34
|
+ // Regular links
|
|
|
35
|
+ else {
|
|
|
36
|
+ next()
|
|
|
37
|
+ }
|
|
27
|
38
|
})
|
|
28
|
39
|
|
|
29
|
40
|
export default router
|