aboutsummaryrefslogtreecommitdiff
path: root/packages/client/src/router/index.js
blob: 69cd0365fb95942f26611b3a9133f29314d8c287 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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;