crate
weft_build
Build-time routes for Weft apps.
A project's build.rs calls run. It reads app/ (pages and layouts, in directories that mirror the site's URLs) and components/ (one component per .weft file), and writes the Rust that weft::app!() includes: the route table, the root template, and every page, layout and component ready to register.
app/layout.weft the root layout (`slot` is where the page goes)
app/page.weft /
app/about/page.weft /about/
app/blog/layout.weft wraps every page under /blog/
app/blog/[slug]/page.weft /blog/:slug/, with `params.slug`
app/blog/[slug]/page.rs its companion: `scope`, `static_params`, `INTERACTIVE`
app/docs/[...path]/page.weft /docs/*path/, with `params.path`
app/(marketing)/pricing/page.weft /pricing/: a group adds no segment
app/_parts/ a directory starting with `_` is never a route
app/not-found.weft what paths no route matches show
components/date-badge.weft `DateBadge`, with `date-badge.rs` as its companionStructs
- App
Everything in
app/andcomponents/. - BuildError
A problem with a file in
app/orcomponents/. - Companion
What a
.rscompanion beside a.weftfile provides. - Page
A page and where it's served.
- Unit
A
.weftfile as a component.
Functions
generate
pub fn generate(app: &App, root: &Path) -> StringThe Rust weft::app!() includes. root is the project root (companion modules are included by absolute path).
run
pub fn run()For a project's build.rs: write $OUT_DIR/weft_app.rs from app/ and components/, and rebuild when they change. Problems stop the build with each file and line.
Constants
DEFAULT_NOT_FOUND
pub const DEFAULT_NOT_FOUND: &str = …;The page shown where no route matches, when there's no not-found.weft.