Skip to content

Commit 2129d5c

Browse files
add title from route
1 parent 56c65d9 commit 2129d5c

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<meta charset="UTF-8" />
55
<link rel="icon" href="/favicon.ico" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>Vuetify 3</title>
87
<!-- FONTS -->
98
<link rel="preconnect" href="https://fonts.googleapis.com" />
109
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />

src/router/index.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
// Composables
2-
import { createRouter, createWebHistory } from "vue-router";
2+
import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
33
import Home from "@/views/Home.vue";
44
import CV from "@/views/CV.vue";
55
import Social from "@/views/Social.vue";
6+
import { profile } from "@/models/profile";
7+
import Vue from "vue";
68

7-
export const routes = [
9+
export const routes: RouteRecordRaw[] = [
810
{
911
path: "/",
1012
name: "Accueil",
@@ -16,6 +18,9 @@ export const routes = [
1618
path: "/CV",
1719
name: "CV",
1820
component: CV,
21+
meta: {
22+
title: `CV ${profile.name}`,
23+
},
1924
},
2025
{
2126
path: "/Social",
@@ -29,4 +34,11 @@ const router = createRouter({
2934
routes,
3035
});
3136

37+
router.afterEach((to, from) => {
38+
// Use next tick to handle router history correctly
39+
// see: https://github.com/vuejs/vue-router/issues/914#issuecomment-384477609
40+
document.title =
41+
(to.meta.title as string) || to.name?.toString() || profile.name;
42+
});
43+
3244
export default router;

0 commit comments

Comments
 (0)