Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Static Build

lat theme build writes a theme’s pages and text assets to a directory any static host serves.

lat theme build acme
lat theme build acme --out public --base-url https://acme.example

Every page whose URL has no parameter is written at its URL (/about to about/index.html), the /404 page also as 404.html, a page whose URL names a file (/robots.txt, /sitemap.xml) as that file, and the text assets under themes/<code>/assets/. A clean URL’s canonical link and this.url carry the trailing slash a static host serves it with (/about/). A page with parameters or a hidden page is skipped and named.

FlagDefaultMeaning
--outdistThe output directory.
--base-urlthe application’s app.url, else one derived from server.listenThe origin url() and the canonical link use.
--from <DIR>the project’s theme.folderBuild a theme folder with no application; the folder’s name is the code. See Static Website.
--copy <SRC>:<DEST>the project’s theme.copyA directory copied into the output at <DEST>. Repeatable.

Preview a theme folder

lat theme serve
lat theme serve --from themes/acme --listen 127.0.0.1:3000 --copy docs/book:docs
FlagDefaultMeaning
--from <DIR>the project’s theme.folderThe theme folder.
--listenthe project’s server.listen, else 127.0.0.1:8080The address.
--copy <SRC>:<DEST>the project’s theme.copyAs build --copy.

lat serve in a project with theme.folder is this preview.

Load a theme folder from Rust

use lateritecmf::web::theme::{build, folder};

let loaded = folder::load(Path::new("themes/acme")).await?;
let report = build::build(&loaded.db, &loaded.code, Path::new("dist"), "https://acme.example").await?;
FieldHolds
dbA private in-memory database holding the theme.
codeThe folder’s name.
reportThe ImportReport of the load.

Build from Rust

use lateritecmf::web::theme::build;

let report = build::build(&db, "acme", Path::new("dist"), "https://acme.example").await?;
println!("{} pages, {} assets, {} skipped", report.pages.len(), report.assets.len(), report.skipped.len());

Build from the application

lat theme build renders without an application’s modules; a template that needs their markup or components is built from the application with build::build_with:

let report = build::build_with(
    &db,
    "acme",
    Path::new("dist"),
    "https://acme.example",
    &[Arc::new(Money)],
    &[&ComponentReg::new("acme.posts", "Posts", Arc::new(Posts))],
)
.await?;
ArgumentMeaning
markupThe Markup registrations to install, in order.
componentsThe ComponentReg registrations the pages attach.

A site rendered by your own templating, with no theme, is covered under Static Site Generation.