docs: add router.extendRoutes example to migration docs (#4023)

* docs: add `router.extendRoutes` example to migration docs

* style: lint
This commit is contained in:
Daniel Roe 2022-04-01 14:21:06 +01:00 committed by GitHub
parent 1890c55cbe
commit 59b319b492
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,23 +13,53 @@ Nuxt configuration will be loaded using [`unjs/jiti`](https://github.com/unjs/ji
### Migration
You should migrate to the new `defineNuxtConfig` function that provides a typed configuration schema.
1. You should migrate to the new `defineNuxtConfig` function that provides a typed configuration schema.
::code-group
::code-group
```ts [Nuxt 2]
export default {
// ...
}
```
```ts [Nuxt 2]
export default {
// ...
}
```
```ts [Nuxt 3]
import { defineNuxtConfig } from 'nuxt3'
```ts [Nuxt 3]
import { defineNuxtConfig } from 'nuxt3'
export default defineNuxtConfig({
// ...
})
```
export default defineNuxtConfig({
// ...
})
```
::
1. If you were using `router.extendRoutes` you can migrate to the new `pages:extend` hook:
::code-group
```ts [Nuxt 2]
export default {
router: {
extendRoutes (routes) {
//
}
}
}
```
```ts [Nuxt 3]
import { defineNuxtConfig } from 'nuxt3'
export default defineNuxtConfig({
hooks: {
'pages:extend' (routes) {
//
}
}
})
```
::
#### ESM Syntax