Skip to content

Preview Ideas in CMS (pt. 2/2) - #111

Open
interim17 wants to merge 6 commits into
idea-preview-non-relationfrom
idea-preview-post-leave
Open

Preview Ideas in CMS (pt. 2/2)#111
interim17 wants to merge 6 commits into
idea-preview-non-relationfrom
idea-preview-post-leave

Conversation

@interim17

@interim17 interim17 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Problem

Closes #87 Closes #55

We have no customized preview for idea pages.

Solution

#112 got the preview rendering, what it left unresolved was getting the data from relational widgets.

Relation widgets

Turns out that when widgets have relations (ideas reference allenites, or allenites reference programs) we can get that data via Decap's fieldsMetaData channel, very cool! Previously I thought that was not possible.

But it requires writing resolvers to handle missing data and a do some normalization, which is too bad since we already do all of that in Gatsby. Would be nice if the SSG and the CMS were more integrated.

I had Claude spin up the resolvers in the interest of time and put them in a util folder, since they should be reusable by any other preview down the line that has relational data.

I would say these previews look good enough for now, and are a big improvement over what we had before (nothing). There is not 1:1 visual or functional parity between preview and prod, so I added a little disclaimer at the top.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
Screenshot 2026-07-28 at 10 38 50 AM Screenshot 2026-07-28 at 10 38 56 AM

@netlify

netlify Bot commented Jul 22, 2026

Copy link
Copy Markdown

Deploy Preview for project-idea-board ready!

Name Link
🔨 Latest commit c2ba5d2
🔍 Latest deploy log https://app.netlify.com/projects/project-idea-board/deploys/6a68e9a3e096dd00082dff95
😎 Deploy Preview https://deploy-preview-111--project-idea-board.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@interim17
interim17 marked this pull request as ready for review July 27, 2026 20:27
@interim17
interim17 requested review from meganrm and rugeli and removed request for rugeli July 27, 2026 20:27
@interim17
interim17 marked this pull request as draft July 27, 2026 20:36
@interim17 interim17 changed the title Idea preview post leave Preview Ideas in CMS Jul 28, 2026
Comment on lines +1 to +30
import { ResourceNode } from "../../types";
import { fromImmutable } from "./immutable";

/** Decap's Immutable metadata side-channel, keyed [field, collection, value]. */
export interface FieldsMetaData {
getIn: (path: string[]) => unknown;
}

/**
* Relation widgets (referenced via dropdowns in the CMS) need their cotent resolved
* via Decap's metadata side-channel.
*
* Relation widgets store only the value_field (a name or slug) in entry data;
* Decap stashes the full referenced node in `fieldsMetaData` under
* [field, collection, value]. This is populated asynchronously — on opening an
* existing entry the relation control hydrates the selected values — so this
* returns null until the lookup resolves. Each caller supplies the shape its
* template needs and decides how to handle null (fall back, or filter out).
*/
export function resolveRelation(
fieldsMetaData: FieldsMetaData | undefined,
field: string,
collection: string,
value: string,
): Record<string, unknown> | null {
return fromImmutable<Record<string, unknown>>(
fieldsMetaData?.getIn([field, collection, value]),
);
}

@interim17 interim17 Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is primarily agent written.

We are taking string identifiers like "allenite" for known relation widgets and getting the data out of Decap's fieldsMetaData with the necessary filtering and normalizing.

@interim17
interim17 changed the base branch from main to idea-preview-non-relation July 28, 2026 18:03
@interim17 interim17 changed the title Preview Ideas in CMS Preview Ideas in CMS (pt. 2/2) Jul 28, 2026
@interim17
interim17 marked this pull request as ready for review July 28, 2026 18:12
@interim17
interim17 requested a review from jessicasyu August 4, 2026 20:10
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.

preview for ideas Preview components

1 participant