Site / foldkit-site

NodeBuilder

interface · packages/site/src/index.ts:254

interface NodeBuilder<
  Route extends {
    readonly _tag: string
  },
> {
  readonly node: SiteNode<Route>
  pipe<A>(fn: (builder: NodeBuilder<Route>) => A): A
  title(title: (route: Route) => string): NodeBuilder<Route>
  section(section: string): NodeBuilder<Route>
  landing(landing: Omit<Route, '_tag'>): NodeBuilder<Route>
  shortcut(shortcut: KeySequence): NodeBuilder<Route>
  history(
    history: HistoryIntent | ((prev: Route, next: Route) => HistoryIntent),
  ): NodeBuilder<Route>
  layout(layout: NodeLayout): NodeBuilder<Route>
  view(view: NodeView): NodeBuilder<Route>
  meta<Model = any>(meta: NodeMeta<Route, Model>): NodeBuilder<Route>
  indexed(indexed: boolean): NodeBuilder<Route>
  access<Who>(access: NodeAccess<Who>): NodeBuilder<Route>
  surface<SRoot, SModel, SMessage, SParams>(config: {
    readonly surface: SurfaceType<SRoot, SModel, SMessage, SParams>
    readonly params: (route: Route) => SParams
  }): NodeBuilder<Route>
}

A node under construction, from Site.node: each method annotates and returns the builder, so nodes compose in steps and annotation bundles are ordinary values. Methods — not pipeable fragments — because each stage of a pipe is a separate generic call and could not infer the route. Read .node at any stage for the frozen node so far.

Members

NodeBuilder.node

property · packages/site/src/index.ts:256

readonly node: SiteNode<Route>

The node so far: frozen, usable for targets and hrefs at any stage.

NodeBuilder.pipe

method · packages/site/src/index.ts:272

pipe<A>(fn: (builder: NodeBuilder<Route>) => A): A

One named bundle through the builder, Effect-style: the bundle stays generic over the builder it meets, so it instantiates to this node's route with no annotation. Chain for more than one.

ts
const inSection = <R extends { readonly _tag: string }>(b: NodeBuilder<R>) =>
  b.section('People').shortcut(['G', 'P'])

const Person = Site.node(personRouter, AppRoute.Person).pipe(inSection).node

Free pipe(builder, bundle) from effect composes the same way; this method is the same spelling without the import.

NodeBuilder.title

method · packages/site/src/index.ts:274

title(title: (route: Route) => string): NodeBuilder<Route>

The page's title for this route, once the route value is known.

NodeBuilder.section

method · packages/site/src/index.ts:276

section(section: string): NodeBuilder<Route>

The navigation section this route belongs to.

NodeBuilder.landing

method · packages/site/src/index.ts:278

landing(landing: Omit<Route, '_tag'>): NodeBuilder<Route>

Where the section's nav item points, as this node's params.

NodeBuilder.shortcut

method · packages/site/src/index.ts:280

shortcut(shortcut: KeySequence): NodeBuilder<Route>

The keys that go to this node's landing.

NodeBuilder.history

method · packages/site/src/index.ts:282

history(
  history: HistoryIntent | ((prev: Route, next: Route) => HistoryIntent),
): NodeBuilder<Route>

Which history step a move within this node is.

NodeBuilder.layout

method · packages/site/src/index.ts:286

layout(layout: NodeLayout): NodeBuilder<Route>

A layout wrapping everything under this node.

NodeBuilder.view

method · packages/site/src/index.ts:288

view(view: NodeView): NodeBuilder<Route>

What this node draws for its own route.

NodeBuilder.meta

method · packages/site/src/index.ts:290

meta<Model = any>(meta: NodeMeta<Route, Model>): NodeBuilder<Route>

What this node says of itself in the head, from its route and the Model.

NodeBuilder.indexed

method · packages/site/src/index.ts:292

indexed(indexed: boolean): NodeBuilder<Route>

Whether search engines index this node and the nodes below it.

NodeBuilder.access

method · packages/site/src/index.ts:294

access<Who>(access: NodeAccess<Who>): NodeBuilder<Route>

Who may be shown this node and the nodes below it, and where anyone else goes.

NodeBuilder.surface

method · packages/site/src/index.ts:296

surface<SRoot, SModel, SMessage, SParams>(config: {
  readonly surface: SurfaceType<SRoot, SModel, SMessage, SParams>
  readonly params: (route: Route) => SParams
}): NodeBuilder<Route>

The Surface this route activates.