docs(pages): add information for typing page metadata (#5270)

Co-authored-by: Daniel Roe <daniel@roe.dev>
This commit is contained in:
Robbert van Mourik 2022-06-03 17:35:48 +02:00 committed by GitHub
parent c071b1eb90
commit d61864b1a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -287,6 +287,21 @@ You can define transition properties for the `<transition>` component that wraps
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 strings as defined [here](https://router.vuejs.org/guide/essentials/redirect-and-alias.html#alias) on vue-router documentation.
### Typing Custom Metadata
If you add custom metadata for your pages, you may wish to do so in a type-safe way. It is possible to augment the type of the object accepted by `definePageMeta`:
```ts [index.d.ts]
declare module '#app' {
interface PageMeta {
pageType?: string
}
}
// It is always important to ensure you import/export something when augmenting a type
export {}
```
## Navigation
To navigate between pages of your app, you should use the [`<NuxtLink>`](/api/components/nuxt-link) component.