Skip to content

Commit c3172df

Browse files
authored
Merge pull request TFNS#469 from markfijneman/241-page-titles
Page title improvements
2 parents 118d6bf + cf72e56 commit c3172df

File tree

6 files changed

+29
-17
lines changed

6 files changed

+29
-17
lines changed

front/src/boot/ctfnote.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default boot(async ({ router, redirect, urlPath }) => {
1313
router.afterEach((to) => {
1414
if (typeof to.meta.title == 'string') {
1515
const title = to.meta.title;
16-
document.title = title ? `CTFNote - ${title}` : 'CTFNote';
16+
document.title = title ? `${title} | CTFNote` : 'CTFNote';
1717
}
1818
});
1919

File renamed without changes.

front/src/components/Loader/CTF.vue

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,37 @@
77
<script lang="ts">
88
import ctfnote from 'src/ctfnote';
99
import { defineComponent, watch } from 'vue';
10+
import { useRoute } from 'vue-router';
11+
12+
const setTitle = (ctf: { title: string } | null) => {
13+
if (ctf) {
14+
document.title = `${ctf.title} | CTFNote`;
15+
}
16+
};
1017
1118
export default defineComponent({
1219
props: {
1320
ctfId: { type: Number, required: true },
1421
},
1522
setup(props) {
23+
const route = useRoute();
1624
const { result: ctf } = ctfnote.ctfs.getCtf(() => ({
1725
id: props.ctfId,
1826
}));
1927
20-
watch(ctf, (ctf) => {
21-
if (ctf) {
22-
document.title = `CTFNote - ${ctf.title}`;
23-
}
24-
});
28+
// Watch for manual CTF name changes
29+
watch(ctf, (ctf) => setTitle(ctf));
30+
31+
// Watch for Vue route changes (required to change the title when the page was already mounted)
32+
watch(
33+
() => route.fullPath,
34+
() => setTitle(ctf.value),
35+
);
2536
2637
return { ctf };
2738
},
2839
mounted() {
29-
if (this.ctf) document.title = `CTFNote - ${this.ctf.title}`;
40+
setTitle(this.ctf);
3041
},
3142
});
3243
</script>

front/src/pages/Admin.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<q-page>
33
<q-tabs v-model="tab" indicator-color="secondary" dense align="left">
44
<q-route-tab
5-
:to="{ name: 'admin-registration' }"
5+
:to="{ name: 'admin-authentication' }"
66
label="Authentication"
77
icon="lock"
88
/>

front/src/pages/Task.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default defineComponent({
4646
task,
4747
(task) => {
4848
if (task) {
49-
document.title = `CTFNote - ${task.title}`;
49+
document.title = `${task.title} | ${props.ctf.title} | CTFNote`;
5050
}
5151
},
5252
{ immediate: true },

front/src/router/routes.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ const authRoute: RouteRecordRaw = {
114114
{
115115
path: 'reset-password/:token',
116116
name: 'auth-reset-password',
117-
meta: { public: true, title: 'Register' },
117+
meta: { public: true, title: 'Reset password' },
118118
props: (route) => ({ token: route.params.token }),
119119
component: () => import('components/Auth/ResetPassword.vue'),
120120
},
@@ -132,24 +132,24 @@ const adminRoute: RouteRecordRaw = {
132132
path: 'admin',
133133
name: 'admin',
134134
component: () => import('pages/Admin.vue'),
135-
redirect: { name: 'admin-registration' },
135+
redirect: { name: 'admin-authentication' },
136136
children: [
137137
{
138-
path: 'settings/registration',
139-
name: 'admin-registration',
140-
meta: { title: 'Admin - Registration' },
141-
component: () => import('src/components/Admin/Registration.vue'),
138+
path: 'settings/authentication',
139+
name: 'admin-authentication',
140+
meta: { title: 'Authentication | Admin' },
141+
component: () => import('src/components/Admin/Authentication.vue'),
142142
},
143143
{
144144
path: 'settings/style',
145145
name: 'admin-theme',
146-
meta: { title: 'Admin - Theme' },
146+
meta: { title: 'Theme | Admin' },
147147
component: () => import('src/components/Admin/Theme.vue'),
148148
},
149149
{
150150
path: 'users',
151151
name: 'admin-users',
152-
meta: { title: 'Admin - Users' },
152+
meta: { title: 'Users | Admin' },
153153
component: () => import('components/Admin/Users.vue'),
154154
},
155155
],
@@ -158,6 +158,7 @@ const adminRoute: RouteRecordRaw = {
158158
const teamRoute: RouteRecordRaw = {
159159
path: 'team',
160160
name: 'team',
161+
meta: { title: 'Team' },
161162
component: () => import('src/pages/Team.vue'),
162163
};
163164

0 commit comments

Comments
 (0)