Site / foldkit-site
History, navigation, and head metadata
- History steps (
Site.historyOf(prev, next)): Moving to another node (or from an unknown route) pushes a history entry. Moving within the same node uses that node'shistoryoption — either'push','replace', or a function(prev, next) => 'push' | 'replace'so changing entity IDs pushes while changing search filters replaces. - Navigation bars and shortcuts: Read titles with
Site.titleOfand sections withSite.sectionOf.Site.landing(site, section)finds the first node in a section with alandingtarget, andSite.shortcuts(site, toMessage)produces key bindings forDom.streamFromKeyBindings(refusing shortcuts without a landing or duplicate key bindings). - Head metadata (
metaandindexed): Declaremeta: ({ route, model }) => Metaforfoldkit-ssrsearch and link-preview tags (description,image,type,article,jsonLd), andindexed: falseto keep a node and its descendants out of sitemaps (Site.indexedOf) and search indexes (noindex).Site.metaOf(site, route, model)merges the chain root-first, falling back to the node'stitle:
ts
const Person = Site.node(personRouter, AppRoute.Person)
.title(({ personId }) => `Person ${personId} | Routing`)
.meta<Model>(({ route, model }) => ({ description: model.bios[route.personId] }))
.node
const Nested = Site.route(nestedRouter, AppRoute.Nested, { indexed: false })
const plan = SSR.plan(App, {
id: 'site',
state: Projection.pick(App.model.route, App.model.bios),
meta: model => Site.metaOf(AppSite, model.route, model),
})Any Model field read by meta must be included in the SSR plan's state (such
as the route and resumed fields) so server and client render matching heads.
Nested layouts and views
Site.view(site, route, model, h) draws the deepest matched 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 element explicitly without outlets,
context providers, or nested routers. Ancestors contribute layout only, and
unknown route tags or viewless leaf nodes fail loudly.