feat(router): added legacy routes redirections

This commit is contained in:
Corentin Thomasset 2022-04-16 10:10:21 +02:00
parent fd4426d246
commit dbce46b470
No known key found for this signature in database
GPG key ID: DBD997E935996158
8 changed files with 14 additions and 2 deletions

View file

@ -4,6 +4,11 @@ import HomePage from './pages/Home.page.vue';
import NotFound from './pages/404.page.vue';
import { tools } from './tools';
const toolsRoutes = tools.map(({ path, name, component, ...config }) => ({ path, name, component, meta: { isTool: true, layout: layouts.toolLayout, name, ...config } }));
const toolsRedirectRoutes = tools
.filter(({ redirectFrom }) => redirectFrom && redirectFrom.length > 0)
.flatMap(({ path, redirectFrom }) => redirectFrom?.map((redirectSource) => ({ path: redirectSource, redirect: path })) ?? []);
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
@ -12,7 +17,8 @@ const router = createRouter({
name: 'home',
component: HomePage,
},
...tools.map(({ path, name, component, ...config }) => ({ path, name, component, meta: { isTool: true, layout: layouts.toolLayout, name, ...config } })),
...toolsRoutes,
...toolsRedirectRoutes,
{ path: '/:pathMatch(.*)*', name: 'NotFound', component: NotFound },
],
});