2018-09-02 23:26:15 +03:00
|
|
|
import Router from 'vue-router'
|
|
|
|
|
2018-11-23 16:31:21 +03:00
|
|
|
function createRouter () {
|
2018-09-02 23:26:15 +03:00
|
|
|
return new Router({
|
|
|
|
mode: 'history',
|
|
|
|
fallback: false,
|
2018-10-31 00:09:40 +03:00
|
|
|
scrollBehavior: (to) => {
|
|
|
|
// ads an ability for a scroll to anchor
|
|
|
|
if (to.hash) {
|
|
|
|
return { selector: to.hash }
|
|
|
|
} else {
|
2018-11-25 20:41:15 +03:00
|
|
|
return { x: 0, y: 0 }
|
2018-10-31 00:09:40 +03:00
|
|
|
}
|
|
|
|
},
|
2018-09-02 23:26:15 +03:00
|
|
|
routes: [
|
2018-10-28 18:29:54 +03:00
|
|
|
{
|
|
|
|
path: '/',
|
|
|
|
name: 'Index',
|
|
|
|
component: () => import('../page/Index.vue')
|
|
|
|
},
|
2018-11-25 20:41:15 +03:00
|
|
|
{
|
|
|
|
path: '/haskell/:category',
|
2018-11-23 16:31:21 +03:00
|
|
|
name: 'Category',
|
2018-12-13 15:31:29 +03:00
|
|
|
component: () => import('../page/CategoryPage.vue'),
|
2018-11-25 20:41:15 +03:00
|
|
|
props: (route) => ({ categoryId: route.params.category.split('#').shift().split('-').pop() })
|
2018-11-23 16:31:21 +03:00
|
|
|
},
|
2018-10-28 18:29:54 +03:00
|
|
|
{
|
|
|
|
path: '/haskell/search/results/',
|
|
|
|
name: 'SearchResults',
|
|
|
|
component: () => import('../page/SearchResults.vue'),
|
|
|
|
props: (route) => ({ query: route.query.query })
|
|
|
|
},
|
2018-09-02 23:26:15 +03:00
|
|
|
]
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export {
|
|
|
|
createRouter
|
|
|
|
}
|