Skip to content

feat(renderer): typed field values in themes (RFC-0041 step 6) - #99

Merged
Madraka merged 1 commit into
mainfrom
feat/fields-renderer
Oct 23, 2026
Merged

Madraka merged 1 commit into
mainfrom
feat/fields-renderer

Conversation

@Madraka

@Madraka Madraka commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Step 6, the last step of RFC-0041's rollout (ADR-0043), built on #94–#98.

API (additive only)

  • @cloudhal/core-ts/fields: formatFieldValue(value, def, {locale, defaultLocale?, timeZone?, words?}), plain text per type, as RFC §9 says.
  • @cloudhal/astro-renderer/fields, also re-exported from the root:
    • entryFields(source, entry, options?) and renderFields. Rich text goes through the bodies' Markdown pipeline, URLs through safeHref (an unsafe one is dropped), images become image attributes with the asset's alt in the page's language, and a datetime keeps its zone.
    • Re-exports of resolveFields, fieldLabel and optionLabel.
  • GraphSource.entryFields?, implemented by both the live and snapshot sources; optional, so older sources still type-check.
  • EntryFields.astro: a <dl class="ch-fields"> with one .ch-field[data-field][data-type] per field that has a value, and nothing when none does. No CSS; themes style it.

Starter: the article shows its fields under the cover, and the original's cache tag is added when a value comes from it. Entries without definitions render byte-identically.

Compatibility: the old-theme test now also builds a frozen copy of the v0.4.0 theme. Before building, it adds a collection with fields, and checks that the old themes still render that entry.

Docs: docs/guides/fields.md (defining fields, operations, localization, theme usage, security), the renderer README, and the AGENTS.md layout.

Tests

  • astro-renderer: 265/265. The new tests cover every type, XSS (script, onerror, javascript:, java\tscript:), translation and language-edition cases, and live/snapshot parity.
  • core-ts: the 6 new tests pass. Locally the Miniflare DO tail fails with EADDRNOTAVAIL, same on clean main.
  • docs: 33/33.
  • CLI: 173/173, including the compat test with two frozen themes and a new e2e test: fields render in English and Turkish, injected markup is escaped, and the hello-world <article> is byte-identical.

Changeset: minor (astro-renderer, core-ts, cli).

🤖 Generated with Claude Code

- core-ts/fields: formatFieldValue, plain text per type and locale.
- astro-renderer: entryFields / renderFields (rich text through the
  body Markdown pipeline, URLs through safeHref, images as image
  attributes with the asset's alt), GraphSource.entryFields on live and
  snapshot sources, and EntryFields.astro (a <dl>, nothing when empty).
  Additive only.
- Starter: the article shows its fields; entries without definitions
  render byte-identically.
- Old-theme compat test also builds a frozen v0.4.0 theme, with a
  collection that has fields.
- docs/guides/fields.md; renderer README; AGENTS.md layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Madraka <8898640+Madraka@users.noreply.github.com>
@Madraka
Madraka merged commit 02e314d into main Oct 23, 2026
5 checks passed
@Madraka
Madraka deleted the feat/fields-renderer branch October 23, 2026 04:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant