feat(schema): expose `RouterOptions` and `RouterConfigOptions` (#3713)

This commit is contained in:
pooya parsa 2022-03-16 19:13:05 +01:00 committed by GitHub
parent 12304909bc
commit 3f91d83a79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 7 deletions

View File

@ -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({

View File

@ -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
*/

View File

@ -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'

View File

@ -1,2 +0,0 @@
// TODO: Lost!
export interface NuxtRoute { }

View 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'>