From a61a5771a4fb31ca0a7bc373187042ad220d1f28 Mon Sep 17 00:00:00 2001 From: Valerio Ageno Date: Wed, 1 May 2024 19:33:40 +0200 Subject: [PATCH] feat: add note about router-generator --- packages/router-generator/README.md | 44 +++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/packages/router-generator/README.md b/packages/router-generator/README.md index b9b54407..b34f990b 100644 --- a/packages/router-generator/README.md +++ b/packages/router-generator/README.md @@ -2,3 +2,47 @@ This package handle the creation of the routes. Basically collects and manages them in a single entry point file. + +## Generated route file + +Currently the generator file is very similar to `@tanstack/router` one but since it does not need the same +configurability is up to strong updates. + +```tsx +// This file is auto-generated by Tuono + +import { Route as rootRoute } from './routes/__root' +import { Route as AboutImport } from './routes/about' +import { Route as IndexImport } from './routes/index' + +// Create/Update Routes + +const AboutRoute = AboutImport.update({ + path: '/about', + getParentRoute: () => rootRoute, +} as any) + +const IndexRoute = IndexImport.update({ + path: '/', + getParentRoute: () => rootRoute, +} as any) + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/react-router' { + interface FileRoutesByPath { + '/': { + preLoaderRoute: typeof IndexImport + parentRoute: typeof rootRoute + } + '/about': { + preLoaderRoute: typeof AboutImport + parentRoute: typeof rootRoute + } + } +} + +// Create and export the route tree + +export const routeTree = rootRoute.addChildren([IndexRoute, AboutRoute]) +```