aboutsummaryrefslogtreecommitdiff
path: root/packages/client/src/router/index.ts
blob: 27ea9787d194bd930d8103998ecbc8e955416cb4 (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
47
48
49
50
51
52
53
54
import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";

const routes: RouteRecordRaw[] = [
	{
		path: "/",
		name: "Home",
		component: () => import("../views/Home.vue")
	},
	{
		path: "/:repo([a-zA-Z0-9\\.\\-_]+)",
		name: "Repository",
		component: () => import("../views/Repository.vue"),
		props: route => ({ repository: route.params.repo }),
		children: [
			{
				path: "about",
				name: "About",
				component: () => import("../views/RepositoryAbout.vue")
			},
			{
				path: "log",
				name: "Log",
				component: () => import("../views/RepositoryLog.vue")
			},
			{
				path: "log/:commit([a-fA-F0-9]{40}$)",
				name: "Commit",
				component: () => import("../views/RepositoryCommit.vue"),
				props: route => ({ commit: route.params.commit })
			},
			{
				path: "tree/:path*",
				name: "Tree",
				component: () => import("../views/RepositoryTree.vue"),
				props: route => ({ pathArr: route.params.path ? route.params.path : [] })
			}
			/* {
				path: "",
				component: () => import("../views/RepositoryRedirect")
			} */
		]
	},
	{
		path: "/:PageNotFound(.*)*",
		component: () => import("../views/PageNotFound.vue")
	}
];

const router = createRouter({
	history: createWebHashHistory(),
	routes
});

export default router;