mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 07:32:01 +00:00
docs: add router.extendRoutes
example to migration docs (#4023)
* docs: add `router.extendRoutes` example to migration docs * style: lint
This commit is contained in:
parent
1890c55cbe
commit
59b319b492
@ -13,23 +13,53 @@ Nuxt configuration will be loaded using [`unjs/jiti`](https://github.com/unjs/ji
|
|||||||
|
|
||||||
### Migration
|
### 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]
|
```ts [Nuxt 2]
|
||||||
export default {
|
export default {
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
```ts [Nuxt 3]
|
```ts [Nuxt 3]
|
||||||
import { defineNuxtConfig } from 'nuxt3'
|
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
|
#### ESM Syntax
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user