Skip to content

Commit

Permalink
DRY up title definitions in router config
Browse files Browse the repository at this point in the history
  • Loading branch information
anttimaki committed Dec 13, 2022
1 parent 7b07bc0 commit 20ea2c2
Showing 1 changed file with 12 additions and 31 deletions.
43 changes: 12 additions & 31 deletions src/router/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { RouteConfig } from 'vue-router';
import Profile from '../model/Profile';
import ManagerInformation from '../_managerinf/ManagerInformation';

const appTitle = `${ManagerInformation.APP_NAME} (${ManagerInformation.VERSION.toString()})`
const appTitle = () => `${ManagerInformation.APP_NAME} (${ManagerInformation.VERSION.toString()})`;
const profileTitle = () => `${appTitle()} - ${Profile.getActiveProfile().getProfileName()}`;

const routes: RouteConfig[] = [
{
Expand All @@ -11,19 +12,15 @@ const routes: RouteConfig[] = [
components: {
content: () => import("pages/GameSelectionScreen.vue")
},
meta: {
title: () => appTitle
}
meta: {title: appTitle}
},
{
name: 'splash',
path: '/splash',
components: {
content: () => import('pages/Splash.vue')
},
meta: {
title: () => appTitle
}
meta: {title: appTitle}
},
{
name: 'linux',
Expand All @@ -41,9 +38,7 @@ const routes: RouteConfig[] = [
components: {
content: () => import('pages/Profiles.vue')
},
meta: {
title: () => appTitle
}
meta: {title: appTitle}
},
{
name: 'manager',
Expand All @@ -52,9 +47,7 @@ const routes: RouteConfig[] = [
content: () => import('pages/Manager.vue'),
navigation: () => import('components/navigation/NavigationMenu.vue')
},
meta: {
title: () => `${appTitle} - ${Profile.getActiveProfile().getProfileName()}`
},
meta: {title: profileTitle},
children: [
{
name: 'manager.installed',
Expand All @@ -63,29 +56,23 @@ const routes: RouteConfig[] = [
components: {
subview: () => import('components/views/InstalledModView.vue')
},
meta: {
title: () => `${appTitle} - ${Profile.getActiveProfile().getProfileName()}`
},
meta: {title: profileTitle},
},
{
name: 'manager.online',
path: 'online/',
components: {
subview: () => import('components/views/OnlineModView.vue')
},
meta: {
title: () => `${appTitle} - ${Profile.getActiveProfile().getProfileName()}`
},
meta: {title: profileTitle},
},
{
name: 'manager.settings',
path: 'settings/',
components: {
subview: () => import('components/settings-components/SettingsView.vue')
},
meta: {
title: () => `${appTitle} - ${Profile.getActiveProfile().getProfileName()}`
}
meta: {title: profileTitle}
}
]
},
Expand All @@ -96,9 +83,7 @@ const routes: RouteConfig[] = [
content: () => import('pages/ConfigEditor.vue'),
navigation: () => import('components/navigation/NavigationMenu.vue')
},
meta: {
title: () => `${appTitle} - ${Profile.getActiveProfile().getProfileName()}`
}
meta: {title: profileTitle}
},
{
name: 'help',
Expand All @@ -107,9 +92,7 @@ const routes: RouteConfig[] = [
content: () => import('pages/Help.vue'),
navigation: () => import('components/navigation/NavigationMenu.vue')
},
meta: {
title: () => `${appTitle} - ${Profile.getActiveProfile().getProfileName()}`
}
meta: {title: profileTitle}
},
{
name: 'downloads',
Expand All @@ -118,9 +101,7 @@ const routes: RouteConfig[] = [
content: () => import('pages/DownloadMonitor.vue'),
navigation: () => import('components/navigation/NavigationMenu.vue')
},
meta: {
title: () => `${appTitle} - ${Profile.getActiveProfile().getProfileName()}`
}
meta: {title: profileTitle}
}
];

Expand Down

0 comments on commit 20ea2c2

Please sign in to comment.