mola-sitegen1
Owns HTML IR, rendering, and filesystem emission into dist/.
Wren, Zig, HTML IR, WASM
Architecture
Owns HTML IR, rendering, and filesystem emission into dist/.
Owns the embedded Wren VM and foreign-function bindings.
Owns page composition, copy, loops, and static site declarations.
Owns live demo state, fetching strategy, and client-side rendering.
Build-time flow
src/main.zig configures the embedded runtime.
wren/main.wren calls Site.page(...) and Site.asset(...).
src/sitegen_binding.zig maps Wren calls into native html.Node values.
Pages, CSS, JS, and app.wasm become normal static files.
Browser flow
It discovers DOM roots and instantiates app.wasm.
Mode changes, fetch sequencing, and rendering stay in Zig.
fetch, DOM writes, and event attachment stay in the host.
The runtime still renders browser fragments through mola-sitegen1 HTML IR.
Code example
Wren stays expressive and small while Zig keeps ownership of the actual HTML node model.
class Html {
static h2(className, text) {
return Html.el("h2", [Html.attr("class", className)], [Html.text(text)])
}
}
Site.page("/architecture/index.html", "Architecture", "How the project fits together.", Pages.architecture(posts))Code example
The host boundary is explicit. Wren does not bypass Zig to emit files.
if (std.mem.eql(u8, class_name, "Node")) {
if (std.mem.eql(u8, sig, "text(_)")) return nodeText;
if (std.mem.eql(u8, sig, "el(_,_,_)")) return nodeEl;
}
if (std.mem.eql(u8, class_name, "Site")) {
if (std.mem.eql(u8, sig, "page(_,_,_,_)")) return sitePage;
}Code example
The browser host is deliberately small. Zig owns the app logic and asks JS for browser capabilities.
extern "env" fn jsFetch(panel_index: u32, request_id: u32, phase: u32, url_ptr: u32, url_len: u32) void;
pub export fn selectMode(panel_index: u32, mode_ptr: u32, mode_len: u32) void {
const mode = ptrToConstSlice(mode_ptr, mode_len);
startFeedRequest(panel_index, mode) catch logError("failed to switch live panel mode");
}Project map
Registers the pages and assets for the static build.
Contains the project-site page composition.
Foreign binding layer from Wren into Zig HTML IR.
Shared renderer for browser-side HTML fragments.
Stateful WASM runtime for the demo page.
Browser host bridge only.