diff options
Diffstat (limited to 'packages/client/src/router/index.js')
-rw-r--r-- | packages/client/src/router/index.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/packages/client/src/router/index.js b/packages/client/src/router/index.js new file mode 100644 index 0000000..69cd036 --- /dev/null +++ b/packages/client/src/router/index.js @@ -0,0 +1,46 @@ +import { createRouter, createWebHashHistory } from "vue-router"; +import Home from "../views/Home"; + +const routes = [ + { + path: "/", + name: "Home", + component: Home + }, + { + path: "/:repo([a-zA-Z0-9\\.\\-_]+)", + name: "Repository", + component: () => import("../views/Repository"), + props: route => ({ repository: route.params.repo }), + children: [ + { + path: "log", + name: "Repository Log", + component: () => import("../views/RepositoryLog") + }, + { + path: "log/:commit([a-fA-F0-9]{40}$)", + name: "Commit", + component: () => import("../views/RepositoryCommit"), + props: route => ({ commit: route.params.commit }) + }, + { + path: "tree/:path*", + name: "Tree Entry", + component: () => import("../views/RepositoryTree"), + props: route => ({ pathArr: route.params.path ? route.params.path : [] }) + }, + { + path: "", + redirect: to => `/${to.params.repo}/log` + } + ] + } +]; + +const router = createRouter({ + history: createWebHashHistory(), + routes +}); + +export default router; |