1
1
mirror of https://github.com/aelve/guide.git synced 2024-12-26 14:23:14 +03:00
guide/front/client/router/index.ts

40 lines
936 B
TypeScript
Raw Normal View History

import Router from 'vue-router'
function createRouter () {
return new Router({
mode: 'history',
fallback: false,
scrollBehavior: (to) => {
// ads an ability for a scroll to anchor
if (to.hash) {
return { selector: to.hash }
} else {
return { x: 0, y: 0 }
}
},
routes: [
2018-10-28 18:29:54 +03:00
{
path: '/',
name: 'Index',
component: () => import('../page/Index.vue')
},
{
path: '/haskell/:category',
name: 'Category',
2018-12-13 15:31:29 +03:00
component: () => import('../page/CategoryPage.vue'),
props: (route) => ({ categoryId: route.params.category.split('#').shift().split('-').pop() })
},
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 })
},
]
})
}
export {
createRouter
}