Skip to content

[feature] Define the Posts wiring contract and ship collection-query — the first data-driven block #455

Closed

Description

@Ducksss

Problem

The catalog advertises 8 post components as "in development" on /components. They exist in exactly one place — src/lib/site.ts:1194 — with no source, manifest, registry entry, docs, or demo twin. ROADMAP.md has tracked them since #123–#126 / #132–#135.

Before any of them gets written, we need to settle how post surfaces install, because the assumption baked into AGENTS.md doesn't survive contact with the target repo.

AGENTS.md currently specs them as "shadcn-native post components — file-only shadcn add, no Payload wiring." That is the weakest offer we could ship into the one tier where WordPress is strongest (>50% of WP core blocks are dynamic content blocks: Query Loop, post-*, comments, pagination). File-only components are pasted, not wired — which is the exact thing our positioning says we don't do.

The finding that reframes this

Two facts about payloadcms/payload/templates/website (our only supportedTargets entry, payload-website-starter):

  1. The Posts collection has no blocks layout field. It has title, heroImage, content (Lexical richText), relatedPosts, categories, meta, publishedAt, authors, slug. There is no name: 'layout' / type: 'blocks' array.

    Our entire pagesLayout fragment kind targets that field — support-matrix.json lists name: 'layout' and type: 'blocks' in src/collections/Pages/index.ts as required anchors. There is nothing equivalent on Posts to patch. A "post block" in the page-block sense cannot exist in this target.

  2. The starter already ships an archive block with populateBy (collection | selection), relationTo, categories, limit, selectedDocs. Any query block we ship lands next to an incumbent with a claimed slug.

So "build the 8 post components" isn't one piece of work — it's three different install routes, and most of the 8 aren't post components at all.

Reclassifying the 8

Declared slug What it actually is Route
post-archive a Page block that queries Posts A
post-list a Page block that queries Posts A
featured-post a Page block that queries Posts A
related-posts a Page block that queries Posts A
newsletter-callout a plain Page block, no query at all A (ships today, no new work)
post-card shared presentational primitive consumed by the above shared file
post-hero post template surface C
author-card post template surface C

Route A — Page-installed query blocks. Install onto Pages through the existing pagesLayout + renderBlocks fragments. Zero installer changes. Five of the eight land here.

Route B — Lexical inline blocks. Blocks inside the post body's richText. Needs a new fragment kind + anchor. Note the starter's src/fields/defaultLexical.ts registers no BlocksFeature — only Paragraph/Underline/Bold/Italic/Link — so the blocks list lives in the collection-level editor config, not the shared default. Anchor location unverified; treat as research.

Route C — Post template composition. Components composed into src/app/(frontend)/posts/[slug]/page.tsx. Not editor-managed. This is the file-only mode AGENTS.md describes — appropriate here, but it should be an explicit exception for two components, not the plan for all eight.

Decisions this issue needs to close

D1. Posts family = Page-installed query blocks (recommended).
Reclassify the 8 per the table. Ship Route A first; Route C as an explicit file-only exception; Route B deferred to its own issue. Update AGENTS.md — the blanket "post components are file-only" line becomes wrong the moment we do this.

D2. Slug collision with the starter's archive block.
Options: (a) distinct slugs (collectionQuery, postList) and leave archive alone — recommended, non-destructive, and our fragment dedup already keys on blockSlug; (b) position as a drop-in replacement, which means touching a block we didn't install. Pick (a).

D3. Target requirements when Posts doesn't exist.
support-matrix.json currently requires components.json, src/payload.config.ts, src/blocks/RenderBlocks.tsx, src/collections/Pages/index.ts. A query block additionally needs a Posts collection. Options:

  • (a) add per-component required files/anchors to the manifest, so add refuses with a clear message and doctor reports it — recommended
  • (b) generate a Posts collection on install — large blast radius, rejects our "reviewable diff" principle
  • (c) document it as a prerequisite and fail at runtime — worst option

(a) means a manifest schema addition (requires / requiredAnchors) plus a checkRecordedComponent branch in commands/doctor.ts. Small, and it generalizes to every future data-driven block.

D4. Which collection can it query?
Starter's archive hardcodes relationTo: 'posts'. Do we hardcode, or make the collection selectable? Selectable is more useful and more work (needs the consumer's collection list at config time). Recommend: hardcode posts for v1, leave a note.

Scope

Ships in this issue:

  • collection-query — the wired Page block. Fields: populateBy (collection | selection), categories, limit, sort, selectedDocs, layout (grid | list | featured). Server component, real payload.find, draft-aware.
  • post-card as a shared source file under src/blocks/shared/, consumed by the above.
  • Full bundle per AGENTS.md: source + manifest + registry entry + docs + demo twin + installer test coverage.
  • support-matrix.json / manifest schema change from D3.
  • AGENTS.md correction from D1.

Follow-ups (separate issues, do not scope-creep here):

  • collection-pagination, collection-filters, collection-empty
  • Route B fragment kind for Lexical inline blocks
  • Route C file-only post-hero / author-card
  • comments-thread (Payload ships no official comments plugin — genuine differentiator, but it needs a collection, moderation, and spam handling; it is not a component-sized problem)

Test contract impact — read before estimating

Every one of our 67 blocks is presentational. No block in payload-components/source/blocks/ reads from the database; the relationTo hits in existing configs are all media uploads. collection-query would be the first block whose content comes from a query at render time, and two green gates assume otherwise:

  • tests/int/demo-twins.int.spec.ts mirrors className literals from source into the twin. A twin for a query-driven block has no fixed content to mirror — it needs fixture data, and the mirror rule needs a defined boundary (mirror the shell, not the rows?).
  • tests/e2e/components-visual.e2e.spec.ts snapshots the twin per platform. Query output must be deterministic or the baseline flaps. Fixture data must be committed, not generated.

Also in scope to think about, not necessarily to solve: depth/population cost, draft vs published in live preview, and caching/revalidation on the consumer's page.

Catalog count pins: literal component counts are pinned in the fumadocs-site int spec and the frontend e2e spec, plus spelled-out prose. Adding a shipped component moves all of them. ROADMAP.md also still says 58 blocks; actual is 67.

Acceptance criteria

  • D1–D4 decided and recorded in the issue thread
  • AGENTS.md two-install-modes section corrected
  • collection-query ships as a complete bundle (source, manifest, registry, docs, twin, tests)
  • add refuses cleanly on a target with no Posts collection, with an actionable message
  • doctor reports the missing prerequisite rather than failing opaquely
  • Install is idempotent and recoverable after a partial run (existing state contract)
  • Demo twin is deterministic from committed fixture data; visual baselines minted on both platforms
  • src/lib/site.ts entry moves from "in development" to shipped, with command / href / version
  • Count pins and ROADMAP.md updated in the same change
  • pnpm test:release green

Open questions

  1. Is there a second supportedTargets shape we should admit here, or does this stay payload-website-starter-only?
  2. Do we want collection-query to support the starter's selectedDocs manual-curation mode in v1, or collection-mode only?
  3. Should the demo twin show a static three-card grid, or do we introduce a fixture-data concept to the twin system for all future data-driven blocks?

Activity

  1. added
    enhancement
    on Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions