diff --git a/docs/content/3.docs/2.directory-structure/10.pages.md b/docs/content/3.docs/2.directory-structure/10.pages.md index 019f99084d..5f49d145e0 100644 --- a/docs/content/3.docs/2.directory-structure/10.pages.md +++ b/docs/content/3.docs/2.directory-structure/10.pages.md @@ -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 >{ +export default { } ``` ### 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({ diff --git a/packages/schema/src/config/router.ts b/packages/schema/src/config/router.ts index badc8a5db0..e8dae2aa3d 100644 --- a/packages/schema/src/config/router.ts +++ b/packages/schema/src/config/router.ts @@ -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 */ diff --git a/packages/schema/src/index.ts b/packages/schema/src/index.ts index 9f753138ef..74894a134e 100644 --- a/packages/schema/src/index.ts +++ b/packages/schema/src/index.ts @@ -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' diff --git a/packages/schema/src/types/pages.ts b/packages/schema/src/types/pages.ts deleted file mode 100644 index 7d4f24474d..0000000000 --- a/packages/schema/src/types/pages.ts +++ /dev/null @@ -1,2 +0,0 @@ -// TODO: Lost! -export interface NuxtRoute { } diff --git a/packages/schema/src/types/router.ts b/packages/schema/src/types/router.ts new file mode 100644 index 0000000000..a5cb900c0c --- /dev/null +++ b/packages/schema/src/types/router.ts @@ -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