Skip to content

fix(loops): iterate repeater sub-fields and publish bound media URLs - #648

Draft
invisibletype wants to merge 1 commit into
CoreBunch:mainfrom
invisibletype:fix/repeater-media-loops
Draft

invisibletype wants to merge 1 commit into
CoreBunch:mainfrom
invisibletype:fix/repeater-media-loops

Conversation

@invisibletype

Copy link
Copy Markdown

Requested by Arlo

Summary

Before: a loop nested inside a loop over a repeater field rendered nothing, so a case study's blocks could not each list their own images. The Loop panel did not offer repeater fields at all. And an Image (or Video) whose source was bound to a media field published the asset id as src (src="zz4G2c…"), with only srcset pointing at real files.

After: repeater items expose their cells as loop item fields, so {currentEntry.layout} reads a block's value and a nested Current entry field loop can iterate that block's images. The Field picker offers repeater fields, and inside a repeater loop it offers that repeater's multi-value sub-fields. Bound images and videos publish the resolved asset URL in src.

How:

  • src/core/loops/sources/entryField.ts: projectItem recognises RepeaterItemSchema items and spreads cells into the item fields (the original item stays at value). This is a deliberate shape change: bindings that reached into cells.* now read the sub-field directly.
  • LoopPropertiesView.tsx: the entry-field picker resolves context from the nearest enclosing loop. Under an entry.field repeater loop it lists that repeater's sub-fields, otherwise the context tables' collection fields, now including repeaters.
  • base.image / base.video: src prefers _resolvedMediaByKey[...].publicPath. Authored URLs resolve to an asset with the same path, so their output is unchanged.
  • docs/features/loops.md: picker behaviour plus a "case-study blocks from a repeater" recipe.

Checked end to end on a local SQLite instance: a post type with a blocks repeater (layout select + multi-media images), an entry template with a blocks loop, a data-layout="{currentEntry.layout}" section, and a nested images loop. Every block published only its own images with /uploads/... src values.

Verification

  • bun run build: passes
  • bun test: the changed suites pass (153 tests). The new repeater and nested-loop tests fail without the fix. The full run on Windows has 24 failures that are unrelated: symlink EPERM, missing server-artifact binaries, one SQLite timeout, and architecture gates on files outside this diff. src/__tests__/architecture gives the same 9 failures with and without this change.
  • bun run lint: passes
  • Docker/deployment check, if relevant (not relevant)

Checklist

  • Tests cover behavior changes.
  • Docs were updated when behavior, config, deployment, or public surfaces changed.
  • No compatibility shim was added for old pre-release behavior.
  • No secrets, local databases, uploads, or generated artifacts are included.

🤖 Generated with Claude Code

…edia URLs

Repeater items ({ id, cells }) now expose their cells as loop item fields,
so a loop nested in a repeater loop can iterate an item's own multi-value
sub-field (a case-study block's images), and the Loop panel offers repeater
fields plus a repeater's sub-fields inside a repeater loop.

base.image and base.video now take src from the resolved media asset, so a
src bound to a media field publishes the asset URL instead of its id.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

This branch has not been deployed

No deployments
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