Expand description
Build-script support for rok-ui.
routes scans src/routes/ and generates a typed route tree, the way TanStack Router’s
generator writes routeTree.gen.ts: one route type per page file, a module per file, and a
tree() function that builds the Router.
// build.rs
rok_ui_build::routes("src/routes").generate().unwrap();// src/main.rs
rok_ui::routes!(); // includes the generated `routes` module
// ... RouterProvider: routes::tree()File conventions (names relative to the routes directory):
| File | Route |
|---|---|
__root.rs | The root layout, around every route |
__not_found.rs | Shown when nothing matches (inside the root layout) |
index.rs | / (the index of its folder) |
about.rs | /about |
notes.rs with layout: | A layout for every route under /notes |
notes/index.rs | /notes |
notes/$id.rs | /notes/:id |
notes.$id.edit.rs | /notes/:id/edit (dots separate segments) |
files/$.rs | /files/*splat |
_auth.rs with layout: | A layout without a path segment, around _auth/.. |
(marketing)/pricing.rs | /pricing (a group folder only organizes files) |
-components/.. | Ignored: colocated helpers |
A file that declares layout: .. in its file_route! wraps every route below its path;
one that declares component: .. is a page.
| [rok-ui].rs | /rok-ui (brackets escape special characters) |
Structs§
Enums§
- Error
- Why routes could not be generated.
Functions§
- routes
- Generate routes from the files in
dir(relative to the crate root in a build script).