2019-05-20 04:41:28 -04:00
|
|
|
import Vue from 'vue';
|
|
|
|
import VueRouter from 'vue-router';
|
|
|
|
import { joinPaths } from '../lib/utils/url_utility';
|
|
|
|
import IndexPage from './pages/index.vue';
|
|
|
|
import TreePage from './pages/tree.vue';
|
|
|
|
|
|
|
|
Vue.use(VueRouter);
|
|
|
|
|
|
|
|
export default function createRouter(base, baseRef) {
|
|
|
|
return new VueRouter({
|
|
|
|
mode: 'history',
|
|
|
|
base: joinPaths(gon.relative_url_root || '', base),
|
|
|
|
routes: [
|
|
|
|
{
|
2020-02-05 10:08:48 -05:00
|
|
|
path: `(/-)?/tree/${escape(baseRef)}/:path*`,
|
2019-05-20 04:41:28 -04:00
|
|
|
name: 'treePath',
|
|
|
|
component: TreePage,
|
|
|
|
props: route => ({
|
2020-02-05 10:08:48 -05:00
|
|
|
path: route.params.path?.replace(/^\//, '') || '/',
|
2019-05-20 04:41:28 -04:00
|
|
|
}),
|
|
|
|
},
|
2019-05-24 05:39:18 -04:00
|
|
|
{
|
|
|
|
path: '/',
|
|
|
|
name: 'projectRoot',
|
|
|
|
component: IndexPage,
|
|
|
|
},
|
2019-05-20 04:41:28 -04:00
|
|
|
],
|
|
|
|
});
|
|
|
|
}
|