mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
feat(schema): expose RouterOptions
and RouterConfigOptions
(#3713)
This commit is contained in:
parent
12304909bc
commit
3f91d83a79
@ -274,16 +274,22 @@ It is possible to set default [vue-router options](https://router.vuejs.org/api/
|
||||
This is the recommaned way to specify router options.
|
||||
|
||||
```js [app/router.options.ts]
|
||||
import type { RouterOptions } from 'vue-router'
|
||||
import type { RouterOptions } from '@nuxt/schema'
|
||||
|
||||
// https://router.vuejs.org/api/#routeroptions
|
||||
export default <Partial<RouterOptions>>{
|
||||
export default <RouterOptions>{
|
||||
}
|
||||
```
|
||||
|
||||
### Using `nuxt.config`
|
||||
|
||||
**Note:** Only JSON serializable options shall be passed. Non serializable options including `parseQuery`, `scrollBehavior` and `stringifyQuery` should be set using `app/router.options` file.
|
||||
**Note:** Only JSON serializable options are configurable:
|
||||
|
||||
- `linkActiveClass`
|
||||
- `linkExactActiveClass`
|
||||
- `end`
|
||||
- `sensitive`
|
||||
- `strict`
|
||||
|
||||
```js [nuxt.config]
|
||||
export default defineNuxtConfig({
|
||||
|
@ -9,7 +9,7 @@ export default {
|
||||
* For more control, you can use `app/router.optionts.ts` file.
|
||||
*
|
||||
* @see [documentation](https://router.vuejs.org/api/#routeroptions)
|
||||
* @type {import('vue-router').RouterOptions}
|
||||
* @type {import('../src/types/router').RouterConfigOptions}
|
||||
*
|
||||
* @version 3
|
||||
*/
|
||||
|
@ -10,7 +10,7 @@ export * from './types/imports'
|
||||
export * from './types/meta'
|
||||
export * from './types/module'
|
||||
export * from './types/nuxt'
|
||||
export * from './types/pages'
|
||||
export * from './types/router'
|
||||
|
||||
// Schema
|
||||
export { default as NuxtConfigSchema } from './config/index'
|
||||
|
@ -1,2 +0,0 @@
|
||||
// TODO: Lost!
|
||||
export interface NuxtRoute { }
|
9
packages/schema/src/types/router.ts
Normal file
9
packages/schema/src/types/router.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import type { RouterOptions as _RouterOptions } from 'vue-router'
|
||||
|
||||
|
||||
export type RouterOptions = Exclude<_RouterOptions, 'history' | 'routes'>
|
||||
|
||||
/**
|
||||
* Only JSON serializable router options are configurable from nuxt config
|
||||
*/
|
||||
export type RouterConfigOptions = Pick<RouterOptions, 'linkActiveClass' | 'linkExactActiveClass' | 'end' | 'sensitive' | 'strict'>
|
Loading…
Reference in New Issue
Block a user