On this page
  1. Hast builders
  2. Context and tree helpers
  3. Types

Render authoring (@glw907/cairn-cms/render)

The component-authoring toolkit a site reaches for inside a component’s build(ctx). These helpers build hast and read the component context. The render pipeline itself stays behind createRenderer on the package root. That function is the one public, safe-by-default render path.

import { cardShell, headRow, iconSpan, strAttr } from '@glw907/cairn-cms/render';

Hast builders

Stability tier: Extension API.

  • cardShell(classes, body) wraps body content in a <section><div class="card-body"> shell.
  • headRow(title, icon?, level?) builds the icon-plus-heading head row; the heading level defaults to 2.
  • iconSpan(glyphEl, role?) wraps a built glyph element in an ec-icon span.

Context and tree helpers

Stability tier: Extension API.

  • strAttr(ctx, key) reads a declared string attribute off the component context, returning undefined for a boolean or absent value.
  • isElement(node) narrows a hast node to an Element.

Types

Stability tier: Extension API.

  • ComponentContext is the structured input a build receives (attributes, slots, the stamped node).
  • MakeIcon is a site’s icon factory signature, (name, role?) => Element.

Edit this page on GitHub(opens in a new tab)