mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 09:27:13 +00:00
470 lines
17 KiB
Plaintext
470 lines
17 KiB
Plaintext
{
|
|
"pushed route, skips generation from file": [
|
|
{
|
|
"alias": "["pushed-route-alias"].concat(mockMeta?.alias || [])",
|
|
"component": "() => import("pages/route-file.vue").then(m => m.default || m)",
|
|
"meta": "{ ...(mockMeta || {}), ...{"someMetaData":true} }",
|
|
"name": "mockMeta?.name ?? "pushed-route"",
|
|
"path": "mockMeta?.path ?? "/"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
],
|
|
"route without file": [
|
|
{
|
|
"alias": "["sweet-home"]",
|
|
"meta": "{"hello":"world"}",
|
|
"name": ""home"",
|
|
"path": ""/"",
|
|
},
|
|
],
|
|
"route.meta generated from file": [
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/page-with-meta.vue").then(m => m.default || m)",
|
|
"meta": "{ ...(mockMeta || {}), ...{"test":1} }",
|
|
"name": "mockMeta?.name ?? "page-with-meta"",
|
|
"path": "mockMeta?.path ?? "/page-with-meta"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
],
|
|
"should allow pages with `:` in their path": [
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/test:name.vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "test:name"",
|
|
"path": "mockMeta?.path ?? "/test\\:name"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
],
|
|
"should correctly merge nested routes": [
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"children": [
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"children": [
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/param/index/index.vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "param-index"",
|
|
"path": "mockMeta?.path ?? """,
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("layer/pages/param/index/sibling.vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "param-index-sibling"",
|
|
"path": "mockMeta?.path ?? "sibling"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
],
|
|
"component": "() => import("layer/pages/param/index.vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? undefined",
|
|
"path": "mockMeta?.path ?? """,
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/param/sibling.vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "param-sibling"",
|
|
"path": "mockMeta?.path ?? "sibling"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
],
|
|
"component": "() => import("pages/param.vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? undefined",
|
|
"path": "mockMeta?.path ?? "/param"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"children": [
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("layer/pages/wrapper-expose/other/index.vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "wrapper-expose-other"",
|
|
"path": "mockMeta?.path ?? """,
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/wrapper-expose/other/sibling.vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "wrapper-expose-other-sibling"",
|
|
"path": "mockMeta?.path ?? "sibling"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
],
|
|
"component": "() => import("pages/wrapper-expose/other.vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? undefined",
|
|
"path": "mockMeta?.path ?? "/wrapper-expose/other"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
],
|
|
"should extract serializable values and override fallback when normalized with `overrideMeta: true`": [
|
|
{
|
|
"alias": "["sweet-home"].concat(mockMeta?.alias || [])",
|
|
"component": "() => import("pages/index.vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "home"",
|
|
"path": "mockMeta?.path ?? "/"",
|
|
"redirect": ""/"",
|
|
},
|
|
],
|
|
"should generate correct catch-all route": [
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/[...slug].vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "slug"",
|
|
"path": "mockMeta?.path ?? "/:slug(.*)*"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/index.vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "index"",
|
|
"path": "mockMeta?.path ?? "/"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
],
|
|
"should generate correct dynamic routes": [
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/index.vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "index"",
|
|
"path": "mockMeta?.path ?? "/"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/[slug].vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "slug"",
|
|
"path": "mockMeta?.path ?? "/:slug()"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"children": [
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/[[foo]]/index.vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "foo"",
|
|
"path": "mockMeta?.path ?? """,
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
],
|
|
"component": "() => import("pages/[[foo]]").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? undefined",
|
|
"path": "mockMeta?.path ?? "/:foo?"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/optional/[[opt]].vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "optional-opt"",
|
|
"path": "mockMeta?.path ?? "/optional/:opt?"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/optional/prefix-[[opt]].vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "optional-prefix-opt"",
|
|
"path": "mockMeta?.path ?? "/optional/prefix-:opt?"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/optional/[[opt]]-postfix.vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "optional-opt-postfix"",
|
|
"path": "mockMeta?.path ?? "/optional/:opt?-postfix"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/optional/prefix-[[opt]]-postfix.vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "optional-prefix-opt-postfix"",
|
|
"path": "mockMeta?.path ?? "/optional/prefix-:opt?-postfix"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/[bar]/index.vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "bar"",
|
|
"path": "mockMeta?.path ?? "/:bar()"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/nonopt/[slug].vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "nonopt-slug"",
|
|
"path": "mockMeta?.path ?? "/nonopt/:slug()"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/opt/[[slug]].vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "opt-slug"",
|
|
"path": "mockMeta?.path ?? "/opt/:slug?"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/[[sub]]/route-[slug].vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "sub-route-slug"",
|
|
"path": "mockMeta?.path ?? "/:sub?/route-:slug()"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
],
|
|
"should generate correct id for catchall (order 1)": [
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/[...stories].vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "stories"",
|
|
"path": "mockMeta?.path ?? "/:stories(.*)*"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/stories/[id].vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "stories-id"",
|
|
"path": "mockMeta?.path ?? "/stories/:id()"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
],
|
|
"should generate correct id for catchall (order 2)": [
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/stories/[id].vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "stories-id"",
|
|
"path": "mockMeta?.path ?? "/stories/:id()"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/[...stories].vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "stories"",
|
|
"path": "mockMeta?.path ?? "/:stories(.*)*"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
],
|
|
"should generate correct route for kebab-case file": [
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/kebab-case.vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "kebab-case"",
|
|
"path": "mockMeta?.path ?? "/kebab-case"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
],
|
|
"should generate correct route for snake_case file": [
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/snake_case.vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "snake_case"",
|
|
"path": "mockMeta?.path ?? "/snake_case"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
],
|
|
"should generate correct routes for index pages": [
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/index.vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "index"",
|
|
"path": "mockMeta?.path ?? "/"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/parent/index.vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "parent"",
|
|
"path": "mockMeta?.path ?? "/parent"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/parent/child/index.vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "parent-child"",
|
|
"path": "mockMeta?.path ?? "/parent/child"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
],
|
|
"should generate correct routes for parent/child": [
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"children": [
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/parent/child.vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "parent-child"",
|
|
"path": "mockMeta?.path ?? "child"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
],
|
|
"component": "() => import("pages/parent.vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "parent"",
|
|
"path": "mockMeta?.path ?? "/parent"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
],
|
|
"should handle trailing slashes with index routes": [
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"children": [
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/index/index/all.vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "index-index-all"",
|
|
"path": "mockMeta?.path ?? "all"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
],
|
|
"component": "() => import("pages/index/index.vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "index"",
|
|
"path": "mockMeta?.path ?? "/"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
],
|
|
"should merge route.meta with meta from file": [
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/page-with-meta.vue").then(m => m.default || m)",
|
|
"meta": "{ ...(mockMeta || {}), ...{"test":1} }",
|
|
"name": "mockMeta?.name ?? "page-with-meta"",
|
|
"path": "mockMeta?.path ?? "/page-with-meta"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
],
|
|
"should not generate colliding route names when hyphens are in file name": [
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/parent/[child].vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "parent-child"",
|
|
"path": "mockMeta?.path ?? "/parent/:child()"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/parent-[child].vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "parent-child"",
|
|
"path": "mockMeta?.path ?? "/parent-:child()"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
],
|
|
"should not merge required param as a child of optional param": [
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/[[foo]].vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "foo"",
|
|
"path": "mockMeta?.path ?? "/:foo?"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/[foo].vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "foo"",
|
|
"path": "mockMeta?.path ?? "/:foo()"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
],
|
|
"should only allow "_" & "." as special character for dynamic route": [
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/[a1_1a].vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "a1_1a"",
|
|
"path": "mockMeta?.path ?? "/:a1_1a()"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/[b2.2b].vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "b2.2b"",
|
|
"path": "mockMeta?.path ?? "/:b2.2b()"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/[b2]_[2b].vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "b2_2b"",
|
|
"path": "mockMeta?.path ?? "/:b2()_:2b()"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/[[c3@3c]].vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "c33c"",
|
|
"path": "mockMeta?.path ?? "/:c33c?"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/[[d4-4d]].vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "d44d"",
|
|
"path": "mockMeta?.path ?? "/:d44d?"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
],
|
|
"should properly override route name if definePageMeta name override is defined.": [
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/index.vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "home"",
|
|
"path": "mockMeta?.path ?? "/"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
],
|
|
"should use fallbacks when normalized with `overrideMeta: true`": [
|
|
{
|
|
"alias": "mockMeta?.alias || []",
|
|
"component": "() => import("pages/index.vue").then(m => m.default || m)",
|
|
"meta": "mockMeta || {}",
|
|
"name": "mockMeta?.name ?? "index"",
|
|
"path": "mockMeta?.path ?? "/"",
|
|
"redirect": "mockMeta?.redirect",
|
|
},
|
|
],
|
|
} |