Site / Creating a site
Stateful pages: one placement
Site.placement binds a foldkit-bundle page to its node, parent Model field,
wrapper Message, init args, and arrival Message:
ts
const PeoplePage = Site.placement(PeopleNode, PeopleBundle, {
link: Link.field<Model>()('peoplePage', Link.wrapper(Message.GotPeopleMessage)),
args: parent => ({
searchText: parent.route._tag === 'People' ? parent.route.searchText : Option.none(),
}),
changed: route => PeopleMessage.ChangedRoute({ route }),
})PeoplePage.placed.update folds the child's Messages,
PeoplePage.placed.view renders it, and changed sends the child Message when
its route arrives. For Bundles with OutMessages or non-Bundle submodels, use
Bundle.at and Link.child directly.
Nested rendering without an Outlet
Site.view(site, route, model, h) draws the deepest node's view, wrapped
root-first by every ancestor's layout:
ts
const Section = Site.route(sectionRouter, AppRoute.Section, {
layout: {
render: (child, model, h) => h.div([], [sidebar(model, h), child]),
},
view: {
render: (model, h) => h.ul([], [/* items */]),
},
})Each layout receives its composed child directly without outlets, context
providers, or nested routers. Ancestors contribute layout only, and unknown
tags or viewless leaves fail loudly.