Skip to content

feat: add reference field link resolution for dynamic pages#81

Merged
liamwalder merged 4 commits intodevelopfrom
fix/cms-rendering-issue
Mar 24, 2026
Merged

feat: add reference field link resolution for dynamic pages#81
liamwalder merged 4 commits intodevelopfrom
fix/cms-rendering-issue

Conversation

@tristan-mouchet
Copy link
Copy Markdown
Collaborator

@tristan-mouchet tristan-mouchet commented Mar 23, 2026

Summary

Fix CMS reference field values not rendering on the editor canvas, restrict "Current page item" links to matching collections, add reference field link resolution for dynamic page links, and fix rich text links not rendering correctly in preview and generated pages.

Changes

  • Fix reference fields resolving as empty on canvas by enriching pageCollectionItemData with dotted keys in Canvas.tsx
  • Fix "Current page item" option showing for mismatched-collection links in LinkSettings and RichTextLinkSettings
  • Add ref-page: / ref-collection: link prefixes so dynamic page links can follow a reference field value to its target
  • Handle ref-* link resolution in generateLinkHref (client) and layerToHtml (SSR)
  • Add richTextLink mark handling in renderTiptapToHtml so rich text page/field/asset links render correctly on generated pages
  • Scan rich text Tiptap content for page links in PageRenderer so specific item slugs and ref-* target collections are pre-fetched
  • Add hidePageContextOptions prop to suppress "Current page item" and reference field options when editing CMS item content in CollectionItemSheet
  • Extract shared buildReferenceItemOptions utility and LinkItemOptions component to keep link settings DRY
  • Move REF_PAGE_PREFIX / REF_COLLECTION_PREFIX constants to collection-field-utils to avoid circular dependency
  • Refactor PageRenderer link scanning into module-level pure utilities, replacing two separate tree traversals with a single shared pass

Test plan

  • Create two collections (e.g. Blog + Categories) with a reference field; verify the referenced field value renders on the canvas (not empty)
  • On a Blog dynamic page, link to a Category dynamic page — confirm "Current page item" is hidden when collections differ
  • Select a "Category - Reference field" option and verify the published link resolves to the correct category URL
  • Add a rich text link to a specific CMS item and verify the correct URL renders in preview and on the generated page
  • Add a rich text link using "Current page item" and verify it resolves to the current item's URL in preview
  • Open a rich text field in CollectionItemSheet and confirm "Current page item" and reference field options are not shown
  • Confirm all of the above also works inside a rich text link (via the link popover)

- Enrich page collection item data with dotted relationship keys so reference fields (e.g. Category>Name via Blog) render on canvas
- Restrict "Current page item" link option to pages sharing the same collection, preventing broken cross-collection links
- Enrich page collection item data with dotted keys for canvas
- Restrict "Current page item" to pages sharing same collection
- Add "{FieldName} - Reference field" options for cross-collection links
- Resolve ref-page:* and ref-collection:* at render via item data
@tristan-mouchet tristan-mouchet self-assigned this Mar 23, 2026
@tristan-mouchet tristan-mouchet linked an issue Mar 23, 2026 that may be closed by this pull request
- Add richTextLink mark handling in renderTiptapToHtml (page-fetcher) with full LinkResolutionContext so page/field/ref-* links resolve
- Scan rich text Tiptap content for page links in PageRenderer so specific item slugs and ref-* target collections are pre-fetched
- Add hidePageContextOptions prop to suppress "Current page item" and reference field options when editing CMS item content directly
- Refactor PageRenderer link scanning into module-level pure utilities (collectTiptapPageLinks, collectLayerPageLinks, extractCollectionItemSlugs) replacing two separate tree traversals with a single shared pass
@tristan-mouchet tristan-mouchet linked an issue Mar 23, 2026 that may be closed by this pull request
@liamwalder liamwalder self-assigned this Mar 24, 2026
@liamwalder liamwalder changed the base branch from main to develop March 24, 2026 08:23
@liamwalder liamwalder merged commit 7168acc into develop Mar 24, 2026
2 checks passed
@liamwalder liamwalder deleted the fix/cms-rendering-issue branch March 24, 2026 08:23
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.

bug: linking from rich-text to CMS collection item bug: Linking to CMS page to another CMS page

2 participants