feat: route alias support (#4273)

This commit is contained in:
Victor Saa 2022-04-12 04:09:45 -05:00 committed by GitHub
parent 02b148ae2c
commit 85f2f83cf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -277,6 +277,10 @@ You can define middleware to apply before loading this page. It will be merged w
You can define transition properties for the `<transition>` components that wraps your pages and layouts, or pass `false` to disable the `<transition>` wrapper for that route. You can see a list of options that can be passed [here](https://vuejs.org/api/built-in-components.html#transition) or read [more about how transitions work](https://vuejs.org/guide/built-ins/transition.html#transition).
#### `alias`
You can define page aliases. They allow you to access the same page from different paths. It can be either a string or an array of string as defined [here](https://router.vuejs.org/guide/essentials/redirect-and-alias.html#alias) on vue-router documentation.
## Navigation
To navigate between pages of your app, you should use the [`<NuxtLink>`](/api/components/nuxt-link) component.

View File

@ -237,6 +237,7 @@ export function normalizeRoutes (routes: NuxtPage[], metaImports: Set<string> =
...Object.fromEntries(Object.entries(route).map(([key, value]) => [key, JSON.stringify(value)])),
children: route.children ? normalizeRoutes(route.children, metaImports).routes : [],
meta: route.meta ? `{...(${metaImportName} || {}), ...${JSON.stringify(route.meta)}}` : metaImportName,
alias: `${metaImportName}.alias || []`,
component: genDynamicImport(file)
}
}))