Complete "Layout Routes"
This commit is contained in:
@@ -11,79 +11,129 @@
|
||||
// Import Routes
|
||||
|
||||
import { Route as rootRoute } from './routes/__root'
|
||||
import { Route as IndexImport } from './routes/index'
|
||||
import { Route as ContactsContractIdImport } from './routes/contacts.$contractId'
|
||||
import { Route as AboutImport } from './routes/about'
|
||||
import { Route as SidebarImport } from './routes/_sidebar'
|
||||
import { Route as SidebarIndexImport } from './routes/_sidebar/index'
|
||||
import { Route as SidebarContactsContractIdImport } from './routes/_sidebar/contacts.$contractId'
|
||||
|
||||
// Create/Update Routes
|
||||
|
||||
const IndexRoute = IndexImport.update({
|
||||
id: '/',
|
||||
path: '/',
|
||||
const AboutRoute = AboutImport.update({
|
||||
id: '/about',
|
||||
path: '/about',
|
||||
getParentRoute: () => rootRoute,
|
||||
} as any)
|
||||
|
||||
const ContactsContractIdRoute = ContactsContractIdImport.update({
|
||||
const SidebarRoute = SidebarImport.update({
|
||||
id: '/_sidebar',
|
||||
getParentRoute: () => rootRoute,
|
||||
} as any)
|
||||
|
||||
const SidebarIndexRoute = SidebarIndexImport.update({
|
||||
id: '/',
|
||||
path: '/',
|
||||
getParentRoute: () => SidebarRoute,
|
||||
} as any)
|
||||
|
||||
const SidebarContactsContractIdRoute = SidebarContactsContractIdImport.update({
|
||||
id: '/contacts/$contractId',
|
||||
path: '/contacts/$contractId',
|
||||
getParentRoute: () => rootRoute,
|
||||
getParentRoute: () => SidebarRoute,
|
||||
} as any)
|
||||
|
||||
// Populate the FileRoutesByPath interface
|
||||
|
||||
declare module '@tanstack/react-router' {
|
||||
interface FileRoutesByPath {
|
||||
'/': {
|
||||
id: '/'
|
||||
path: '/'
|
||||
fullPath: '/'
|
||||
preLoaderRoute: typeof IndexImport
|
||||
'/_sidebar': {
|
||||
id: '/_sidebar'
|
||||
path: ''
|
||||
fullPath: ''
|
||||
preLoaderRoute: typeof SidebarImport
|
||||
parentRoute: typeof rootRoute
|
||||
}
|
||||
'/contacts/$contractId': {
|
||||
id: '/contacts/$contractId'
|
||||
'/about': {
|
||||
id: '/about'
|
||||
path: '/about'
|
||||
fullPath: '/about'
|
||||
preLoaderRoute: typeof AboutImport
|
||||
parentRoute: typeof rootRoute
|
||||
}
|
||||
'/_sidebar/': {
|
||||
id: '/_sidebar/'
|
||||
path: '/'
|
||||
fullPath: '/'
|
||||
preLoaderRoute: typeof SidebarIndexImport
|
||||
parentRoute: typeof SidebarImport
|
||||
}
|
||||
'/_sidebar/contacts/$contractId': {
|
||||
id: '/_sidebar/contacts/$contractId'
|
||||
path: '/contacts/$contractId'
|
||||
fullPath: '/contacts/$contractId'
|
||||
preLoaderRoute: typeof ContactsContractIdImport
|
||||
parentRoute: typeof rootRoute
|
||||
preLoaderRoute: typeof SidebarContactsContractIdImport
|
||||
parentRoute: typeof SidebarImport
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create and export the route tree
|
||||
|
||||
interface SidebarRouteChildren {
|
||||
SidebarIndexRoute: typeof SidebarIndexRoute
|
||||
SidebarContactsContractIdRoute: typeof SidebarContactsContractIdRoute
|
||||
}
|
||||
|
||||
const SidebarRouteChildren: SidebarRouteChildren = {
|
||||
SidebarIndexRoute: SidebarIndexRoute,
|
||||
SidebarContactsContractIdRoute: SidebarContactsContractIdRoute,
|
||||
}
|
||||
|
||||
const SidebarRouteWithChildren =
|
||||
SidebarRoute._addFileChildren(SidebarRouteChildren)
|
||||
|
||||
export interface FileRoutesByFullPath {
|
||||
'/': typeof IndexRoute
|
||||
'/contacts/$contractId': typeof ContactsContractIdRoute
|
||||
'': typeof SidebarRouteWithChildren
|
||||
'/about': typeof AboutRoute
|
||||
'/': typeof SidebarIndexRoute
|
||||
'/contacts/$contractId': typeof SidebarContactsContractIdRoute
|
||||
}
|
||||
|
||||
export interface FileRoutesByTo {
|
||||
'/': typeof IndexRoute
|
||||
'/contacts/$contractId': typeof ContactsContractIdRoute
|
||||
'/about': typeof AboutRoute
|
||||
'/': typeof SidebarIndexRoute
|
||||
'/contacts/$contractId': typeof SidebarContactsContractIdRoute
|
||||
}
|
||||
|
||||
export interface FileRoutesById {
|
||||
__root__: typeof rootRoute
|
||||
'/': typeof IndexRoute
|
||||
'/contacts/$contractId': typeof ContactsContractIdRoute
|
||||
'/_sidebar': typeof SidebarRouteWithChildren
|
||||
'/about': typeof AboutRoute
|
||||
'/_sidebar/': typeof SidebarIndexRoute
|
||||
'/_sidebar/contacts/$contractId': typeof SidebarContactsContractIdRoute
|
||||
}
|
||||
|
||||
export interface FileRouteTypes {
|
||||
fileRoutesByFullPath: FileRoutesByFullPath
|
||||
fullPaths: '/' | '/contacts/$contractId'
|
||||
fullPaths: '' | '/about' | '/' | '/contacts/$contractId'
|
||||
fileRoutesByTo: FileRoutesByTo
|
||||
to: '/' | '/contacts/$contractId'
|
||||
id: '__root__' | '/' | '/contacts/$contractId'
|
||||
to: '/about' | '/' | '/contacts/$contractId'
|
||||
id:
|
||||
| '__root__'
|
||||
| '/_sidebar'
|
||||
| '/about'
|
||||
| '/_sidebar/'
|
||||
| '/_sidebar/contacts/$contractId'
|
||||
fileRoutesById: FileRoutesById
|
||||
}
|
||||
|
||||
export interface RootRouteChildren {
|
||||
IndexRoute: typeof IndexRoute
|
||||
ContactsContractIdRoute: typeof ContactsContractIdRoute
|
||||
SidebarRoute: typeof SidebarRouteWithChildren
|
||||
AboutRoute: typeof AboutRoute
|
||||
}
|
||||
|
||||
const rootRouteChildren: RootRouteChildren = {
|
||||
IndexRoute: IndexRoute,
|
||||
ContactsContractIdRoute: ContactsContractIdRoute,
|
||||
SidebarRoute: SidebarRouteWithChildren,
|
||||
AboutRoute: AboutRoute,
|
||||
}
|
||||
|
||||
export const routeTree = rootRoute
|
||||
@@ -96,15 +146,27 @@ export const routeTree = rootRoute
|
||||
"__root__": {
|
||||
"filePath": "__root.tsx",
|
||||
"children": [
|
||||
"/",
|
||||
"/contacts/$contractId"
|
||||
"/_sidebar",
|
||||
"/about"
|
||||
]
|
||||
},
|
||||
"/": {
|
||||
"filePath": "index.tsx"
|
||||
"/_sidebar": {
|
||||
"filePath": "_sidebar.tsx",
|
||||
"children": [
|
||||
"/_sidebar/",
|
||||
"/_sidebar/contacts/$contractId"
|
||||
]
|
||||
},
|
||||
"/contacts/$contractId": {
|
||||
"filePath": "contacts.$contractId.tsx"
|
||||
"/about": {
|
||||
"filePath": "about.tsx"
|
||||
},
|
||||
"/_sidebar/": {
|
||||
"filePath": "_sidebar/index.tsx",
|
||||
"parent": "/_sidebar"
|
||||
},
|
||||
"/_sidebar/contacts/$contractId": {
|
||||
"filePath": "_sidebar/contacts.$contractId.tsx",
|
||||
"parent": "/_sidebar"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user