2021-03-28 20:14:04 +00:00
import { normalizeURL , withTrailingSlash } from 'ufo'
2022-08-26 15:47:29 +00:00
import { defineUntypedSchema } from 'untyped'
2021-03-28 20:14:04 +00:00
2022-08-26 15:47:29 +00:00
export default defineUntypedSchema ( {
2022-03-15 16:57:41 +00:00
/ * *
2022-08-11 21:25:35 +00:00
* Additional options passed to ` vue-router ` .
2022-03-15 16:57:41 +00:00
*
* Note : Only JSON serializable options should be passed by nuxt config .
*
* For more control , you can use ` app/router.optionts.ts ` file .
*
2022-08-11 21:25:35 +00:00
* @see [ documentation ] ( https : //router.vuejs.org/api/interfaces/routeroptions.html).
2022-03-30 08:17:46 +00:00
* @type { import ( '../src/types/router' ) . RouterConfigSerializable }
2022-03-15 16:57:41 +00:00
*
* @version 3
* /
options : { } ,
2021-04-15 18:49:29 +00:00
/ * *
* Configure the router mode .
*
2022-08-11 21:25:35 +00:00
* For server - side rendering it is not recommended to change it .
2021-08-11 21:48:33 +00:00
* @version 2
2021-04-15 18:49:29 +00:00
* /
2021-03-28 20:14:04 +00:00
mode : 'history' ,
2021-04-15 18:49:29 +00:00
/ * *
* The base URL of the app . For example , if the entire single page application is
2022-08-11 21:25:35 +00:00
* served under ` /app/ ` , then base should use the value ` '/app/' ` .
2021-04-15 18:49:29 +00:00
*
* This can be useful if you need to serve Nuxt as a different context root , from
* within a bigger web site .
2021-08-11 21:48:33 +00:00
* @version 2
2021-04-15 18:49:29 +00:00
* /
2021-03-28 20:14:04 +00:00
base : {
2022-04-19 19:12:28 +00:00
$resolve : ( val , get ) = > val ? withTrailingSlash ( normalizeURL ( val ) ) : get ( 'app' ) . baseURL
2021-03-28 20:14:04 +00:00
} ,
2021-04-15 18:49:29 +00:00
/** @private */
2021-03-28 20:14:04 +00:00
_routerBaseSpecified : {
$resolve : ( _val , get ) = > typeof get ( 'router.base' ) === 'string'
} ,
2021-04-15 18:49:29 +00:00
2021-08-11 21:48:33 +00:00
/** @version 2 */
2021-03-28 20:14:04 +00:00
routes : [ ] ,
2021-04-15 18:49:29 +00:00
/ * *
* This allows changing the separator between route names that Nuxt uses .
*
* Imagine we have the page file ` pages/posts/_id.vue ` . Nuxt will generate the
* route name programmatically , in this case ` posts-id ` . If you change the routeNameSplitter
* config to ` / ` the name will change to ` posts/id ` .
2021-08-11 21:48:33 +00:00
* @version 2
2021-04-15 18:49:29 +00:00
* /
2021-03-28 20:14:04 +00:00
routeNameSplitter : '-' ,
2021-04-15 18:49:29 +00:00
/ * *
* Set the default ( s ) middleware for every page of the application .
2021-08-11 21:48:33 +00:00
* @version 2
2021-04-15 18:49:29 +00:00
* /
2021-03-28 20:14:04 +00:00
middleware : {
$resolve : val = > Array . isArray ( val ) ? val : [ val ] . filter ( Boolean )
} ,
2021-04-15 18:49:29 +00:00
/ * *
* Globally configure ` <nuxt-link> ` default active class .
2021-08-11 21:48:33 +00:00
* @version 2
2021-04-15 18:49:29 +00:00
* /
2021-03-28 20:14:04 +00:00
linkActiveClass : 'nuxt-link-active' ,
2021-04-15 18:49:29 +00:00
/ * *
* Globally configure ` <nuxt-link> ` default exact active class .
2021-08-11 21:48:33 +00:00
* @version 2
2021-04-15 18:49:29 +00:00
* /
2021-03-28 20:14:04 +00:00
linkExactActiveClass : 'nuxt-link-exact-active' ,
2021-04-15 18:49:29 +00:00
/ * *
2022-08-11 21:25:35 +00:00
* Globally configure ` <nuxt-link> ` default prefetch class ( feature disabled by default ) .
2021-08-11 21:48:33 +00:00
* @version 2
2021-04-15 18:49:29 +00:00
* /
2021-03-28 20:14:04 +00:00
linkPrefetchedClass : false ,
2021-04-15 18:49:29 +00:00
/ * *
* You can pass a function to extend the routes created by Nuxt .
*
* @example
* ` ` ` js
2022-04-19 14:46:14 +00:00
* import { fileURLToPath } from 'url'
2021-08-11 21:48:33 +00:00
* export default {
* router : {
* extendRoutes ( routes , resolve ) {
* routes . push ( {
* name : 'custom' ,
* path : '*' ,
2022-04-19 14:46:14 +00:00
* component : fileURLToPath ( new URL ( './pages/404.vue' , import . meta . url ) )
2021-08-11 21:48:33 +00:00
* } )
* }
* }
* }
2021-04-15 18:49:29 +00:00
* ` ` `
2021-08-11 21:48:33 +00:00
* @version 2
2021-04-15 18:49:29 +00:00
* /
2021-03-28 20:14:04 +00:00
extendRoutes : null ,
2021-04-15 18:49:29 +00:00
/ * *
* The ` scrollBehavior ` option lets you define a custom behavior for the scroll
* position between the routes . This method is called every time a page is
2022-08-11 21:25:35 +00:00
* rendered . To learn more about it , see the ` vue-router ` documentation .
2021-04-15 18:49:29 +00:00
*
2022-08-11 21:25:35 +00:00
* @see [ vue - router ` scrollBehavior ` documentation ] ( https : //router.vuejs.org/guide/advanced/scroll-behavior.html).
2021-08-11 21:48:33 +00:00
* @version 2
2021-04-15 18:49:29 +00:00
* /
2021-03-28 20:14:04 +00:00
scrollBehavior : {
$schema : {
deprecated : 'router.scrollBehavior` property is deprecated in favor of using `~/app/router.scrollBehavior.js` file, learn more: https://nuxtjs.org/api/configuration-router#scrollbehavior'
}
} ,
2021-04-15 18:49:29 +00:00
/ * *
* Provide custom query string parse function . Overrides the default .
2021-08-11 21:48:33 +00:00
* @version 2
2021-04-15 18:49:29 +00:00
* /
2021-03-28 20:14:04 +00:00
parseQuery : false ,
2021-04-15 18:49:29 +00:00
/ * *
* Provide custom query string stringify function . Overrides the default .
2021-08-11 21:48:33 +00:00
* @version 2
2021-04-15 18:49:29 +00:00
* /
2021-03-28 20:14:04 +00:00
stringifyQuery : false ,
2021-04-15 18:49:29 +00:00
/ * *
* Controls whether the router should fall back to hash mode when the browser
2022-08-11 21:25:35 +00:00
* does not support history . pushState , but mode is set to history .
2021-04-15 18:49:29 +00:00
*
2022-08-11 21:25:35 +00:00
* Setting this to ` false ` essentially makes every router - link navigation a full
2021-04-15 18:49:29 +00:00
* page refresh in IE9 . This is useful when the app is server - rendered and needs
* to work in IE9 , because a hash mode URL does not work with SSR .
2021-08-11 21:48:33 +00:00
* @version 2
2021-04-15 18:49:29 +00:00
* /
2021-03-28 20:14:04 +00:00
fallback : false ,
2021-04-15 18:49:29 +00:00
/ * *
* Configure ` <nuxt-link> ` to prefetch the code - splitted page when detected within
* the viewport . Requires [ IntersectionObserver ] ( https : //developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) to be supported (see [Caniuse](https://caniuse.com/intersectionobserver)).
2021-08-11 21:48:33 +00:00
* @version 2
2021-04-15 18:49:29 +00:00
* /
2021-03-28 20:14:04 +00:00
prefetchLinks : true ,
2021-04-15 18:49:29 +00:00
/ * *
2022-08-11 21:25:35 +00:00
* When using ` nuxt generate ` with target : 'static' , Nuxt will generate a
2021-04-15 18:49:29 +00:00
* payload . js for each page .
*
* With this option enabled , Nuxt will automatically prefetch the payload of the
2021-08-11 21:48:33 +00:00
* linked page when the ` <nuxt-link> ` is visible in the viewport , making instant navigation .
* @version 2
2021-04-15 18:49:29 +00:00
* /
2021-03-28 20:14:04 +00:00
prefetchPayloads : true ,
2021-04-15 18:49:29 +00:00
/ * *
2022-08-11 21:25:35 +00:00
* If this option is set to ` true ` , trailing slashes will be appended to every
* route . If set to ` false ` , they ' ll be removed .
2021-04-15 18:49:29 +00:00
*
2021-08-11 21:48:33 +00:00
* @warning This option should not be set without preparation and has to
2021-04-15 18:49:29 +00:00
* be tested thoroughly . When setting ` trailingSlash ` to something else than
2022-08-11 21:25:35 +00:00
* ` undefined ` , the opposite route will stop working . Thus , 301 redirects should
2021-04-15 18:49:29 +00:00
* be in place and your internal linking has to be adapted correctly . If you set
2022-08-11 21:25:35 +00:00
* ` trailingSlash ` to ` true ` , then only ` example.com/abc/ ` will work , but not
* ` example.com/abc ` . On ` false ` , it ' s vice - versa .
2021-08-11 21:48:33 +00:00
* @version 2
2021-04-15 18:49:29 +00:00
* /
2021-03-28 20:14:04 +00:00
trailingSlash : undefined
2022-08-26 15:47:29 +00:00
} )