Skip to content
SprecherEast
Issue 786

documentation: Knowledge note for the site module, part 1: pages and the page builder

Back to our plan
Done
documentationfrontendcmstoolingpriority: medium

Type

documentation

Summary

Write the first of two notes on the site module: how CMS pages are drawn, from the hero to each page-builder block, what the editor's choices turn into on the page, and what a page save refreshes.

Problem

Pages are the most edited content, and most of what a page shows is decided by mappers that turn the editor's stored blocks into plain props: the hero's title, the content block's layout, which blocks come from other modules. An agent changing a block today has to trace the config, the mapper and the component.

What the generated reference already shows, so the note doesn't repeat it: pages, opens in a new tab lists every layout block and its fields, relationships and hooks; routes.md lists / and /[slug]; sections, opens in a new tab and the other component pages list the kit pieces used. Missing: what the mappers decide, and which module owns each block.

Proposed fix

Write src/modules/site/README.md from the template. Owner's direction for every note (2026-11-06, Claude session, recorded on #712 and #719): a note explains the behavior and logic of its content types and code (what shows, where, when, who publishes or changes it, and the special rules), never a list of fields; and every link between fields is stated near the top, so no agent has to work it out from the code.

Links between fields the note states up front (each one checked in the code first):

  • The hero's title is the first heading of its rich text; the rest is its description (domain/hero.ts, src/platform/richtext/splitHeadingFromBody.ts in ui/PageHero.tsx); the hero type picks the look (high, medium, low).
  • The content block's layout (single, columns, cards, stats) is picked by the mapper from its columns' sizes; a column with only headings starts a card group (data/mappers.ts, domain/blocks.ts).
  • The archive block stores populateBy (collection or selection), categories, limit (default 10) and selectedDocs; news loads the posts and the registry in src/app/(frontend)/[slug]/pageBlocks.tsx passes them in (cms/archiveBlock.ts, ui/ArchiveBlock.tsx).
  • A pasted map iframe is stored as its address alone, and only a Google map embed address is accepted (cms/mapBlock.ts, src/platform/lib/googleMapsEmbed.ts).
  • publishedAt is set when the request has none (populatePublishedAt); the slug home is served at / (src/platform/payload/documentHref.ts).
  • Blocks from other modules (form, "this week", top issues, the archive's posts) are passed in by src/payload.config.ts and the block registry, so site imports no module (decision 0008, cms/pages.ts, ui/RenderBlocks.tsx).

Behaviors and rules the note must cover (each with the file or test named):

  • Saving or deleting a published page refreshes its path, /, every CMS page and the pages sitemap tag, and the old path when the slug changed (cms/revalidatePage.ts).
  • A draft shows only in draft mode; visitors get the published version (data/pages.ts, use-cases/getPageBySlug.ts); the home page has a starter hero before the seed runs.
  • Site's own blocks reach ui/ as plain props, other modules' as stored (decision 0013, data/mappers.ts); an unknown block type draws nothing, and a new type without a case fails tsc (ui/RenderBlocks.tsx).
  • Map block: a small picture, and the live map opens on a tap (ui/MapBlock.tsx, #764).
  • Call-to-action band colors and the content block's card widths (ui/CallToActionBlock.tsx, ui/ContentBlock.tsx), described as behavior, not props.

Tests to name under "Rules and the tests that protect them": cms/pages.test.ts, cms/mapBlock.test.ts, cms/revalidatePage.test.ts, data/mappers.test.ts, data/mappers.pageHero.test.ts, data/mapBlockMapper.test.ts, ui/RenderBlocks.test.tsx, ui/PageHero.test.tsx, ui/ContentBlock.test.tsx, ui/ArchiveBlock.test.tsx, ui/CallToActionBlock.test.tsx, ui/MapBlock.test.tsx.

Map entry: { "note": "src/modules/site/README.md", "paths": ["src/modules/site/cms/pages.ts", "src/modules/site/cms/hero.ts", "src/modules/site/cms/layoutBlocks.ts", "src/modules/site/cms/*Block.ts", "src/modules/site/cms/revalidatePage.ts", "src/modules/site/data/pages.ts", "src/modules/site/data/mappers.ts", "src/modules/site/domain/blocks.ts", "src/modules/site/domain/hero.ts", "src/modules/site/domain/types.ts", "src/modules/site/ui/*Block.tsx", "src/modules/site/ui/PageHero.tsx", "src/modules/site/ui/RenderBlocks.tsx", "src/modules/site/ui/testing/**", "src/modules/site/use-cases/getPageBySlug.ts", "src/modules/site/index.ts", "src/modules/site/server.ts", "src/modules/site/cms.ts"] }

The site module gets two notes (decision 0019, section 3: a module over 80 lines gets a second note). This one covers CMS pages and the page builder; the header, footer, forum link and redirects are #787's. The map lists files, not src/modules/site/**, so a change to the header doesn't ask for this note. Check the patterns cover every file of the module between the two entries, with no file in both, and adjust them if a file was added since 6ac8e8f.

Acceptance criteria

  • Not done: src/modules/site/README.md follows docs/knowledge/note-template.md and is at most 80 lines.
  • Not done: Between this entry and #787's, every file of src/modules/site/ is covered by exactly one note's paths.
  • Not done: It explains behavior and logic, not fields: no field lists, props tables or route lists. It links the generated pages named above for those.
  • Not done: Right after its opening sentences, a short list states every link between fields named above (relationships, values copied or derived, mapper inputs and the props they become, hooks that copy a value), each with its file.
  • Not done: Every behavior listed above is covered or, if the code turns out different, the note says what the code does and this issue gets a comment saying what changed.
  • Not done: Every statement names the file or test it comes from, checked against the code at the branch's base.
  • Not done: docs/knowledge/index.md gets one short line for the note (a few words after the link). It stays within the budget check.
  • Not done: docs/knowledge/map.json gets the entry above.
  • Not done: npm run agent-context -- --write has been run and its generated rule committed, and npm run agent-context passes. If the budget check fails, this issue is not done; trimming other always-loaded files is not part of this issue.
  • Not done: Known contradictions: For #158: check docs/roles/cms-eng.md against this note and fix only statements of fact the code contradicts (policy file: the PR says so); a rule change goes to #158 as a question. #279, #366 and #531 don't apply. #768 (map block in the Payload guideline, needs owner) is separate and not touched.
  • Not done: No code changes. A bug or gap found in the code goes under the note's "Known gaps" and is filed as its own issue (labeled scope-creep, linked here).
  • Not done: Prettier, Knowledge sync, PR Policy and Agent context pass.

Files likely touched

  • src/modules/site/README.md
  • docs/knowledge/index.md (one line)
  • docs/knowledge/map.json (one entry)
  • .claude/rules/generated/src--modules--site--README.md
  • docs/roles/cms-eng.md (only if a fact is wrong)

Must not touch

  • Code under src/ (the note itself excepted): this issue documents behavior and changes none.
  • Other notes, their generated rules, and the files the other note issues under #712 list.
  • docs/knowledge/note-template.md and the session-start set (CLAUDE.md, AGENTS.md, docs/guidelines/guard-rails.md).
  • docs/architecture/data-model.md, docs/ui/data-types.md, docs/ui/component-set-modules.md: read them and fold this area's facts into the note (decision 0019, section 7); report any drift in them in a comment on #712 instead of editing them, since every note issue reads them.
  • src/modules/README.md, src/platform/README.md, docs/project.md (#725 owns them).
  • The header, footer, forum and redirect files of src/modules/site/ and the second site note (#787).

Open questions

  • Session-start room. The index line needs room at session start, which #799 makes. This issue is blocked by #799 and is not Ready until it lands; the line then stays within the budget check.
  • Dead code first. #728 (the audit, waiting for the owner's keep-or-drop marks) removes unused or unwanted code before a note describes it. This issue is marked blocked by #728; it can start once #728 has settled this area, even if other areas are still open there.
  • Size: not set; a cloud session can't read the board. Suggested: M.

Area

tooling, cms, frontend

Priority

medium


Generated by Claude Code, opens in a new tab

See it on GitHub, opens in a new tab