forked from dullage/flatnotes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrouter.js
More file actions
54 lines (50 loc) · 1.3 KB
/
router.js
File metadata and controls
54 lines (50 loc) · 1.3 KB
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 * as constants from "./constants.js";
import { createRouter, createWebHistory } from "vue-router";
const router = createRouter({
history: createWebHistory(""),
routes: [
{
path: "/",
name: "home",
component: () => import("./views/Home.vue"),
},
{
path: "/login",
name: "login",
component: () => import("./views/LogIn.vue"),
props: (route) => ({ redirect: route.query[constants.params.redirect] }),
},
{
path: "/note/:title",
name: "note",
component: () => import("./views/Note.vue"),
props: true,
},
{
path: "/new",
name: "new",
component: () => import("./views/Note.vue"),
},
{
path: "/search",
name: "search",
component: () => import("./views/SearchResults.vue"),
props: (route) => ({
searchTerm: route.query[constants.params.searchTerm],
sortBy: Number(route.query[constants.params.sortBy]) || undefined,
}),
},
],
});
router.afterEach((to) => {
let title = "flatnotes";
if (to.name === "note") {
if (to.params.title) {
title = `${to.params.title} - ${title}`;
} else {
title = "New Note - " + title;
}
}
document.title = title;
});
export default router;