| 1 | import { createRouter, RouterHistory } from "@tanstack/react-router"; |
| 2 | |
| 3 | import { routeTree } from "./routeTree.gen"; |
| 4 | import { isSidebarUtilityPage } from "./components/sidebar/mainAppLocation"; |
| 5 | |
| 6 | export function getRouter(history: RouterHistory) { |
| 7 | return createRouter({ |
| 8 | routeTree, |
| 9 | history, |
| 10 | context: {}, |
| 11 | scrollRestoration: ({ location }) => isSidebarUtilityPage(location.pathname), |
| 12 | // Route components are split chunks (autoCodeSplitting in vite.config); |
| 13 | // fetching them on hover/focus intent hides the load from the first |
| 14 | // settings or pull-request navigation. |
| 15 | defaultPreload: "intent", |
| 16 | }); |
| 17 | } |
| 18 | |
| 19 | export type AppRouter = ReturnType<typeof getRouter>; |
| 20 | |
| 21 | declare module "@tanstack/react-router" { |
| 22 | interface Register { |
| 23 | router: AppRouter; |
| 24 | } |
| 25 | } |