aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/router/index.js
blob: fc332cd73007a31397f0c5ac3cce5d7d21f71e5e (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, createWebHistory } from "vue-router";
import Home from "../views/Home";
import Repository from "../views/Repository";
import RepositoryLog from "../views/RepositoryLog";
import RepositoryCommit from "../views/RepositoryCommit";
import RepositoryTree from "../views/RepositoryTree";

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

const router = createRouter({
	history: createWebHistory(process.env.BASE_URL),
	routes
});

export default router;