Preview Ideas in CMS (pt. 2/2) - #111
Open
interim17 wants to merge 6 commits into
Open
Conversation
… for preview rendering in the idea post template
✅ Deploy Preview for project-idea-board ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
interim17
marked this pull request as ready for review
July 27, 2026 20:27
interim17
requested review from
meganrm and
rugeli
and removed request for
rugeli
July 27, 2026 20:27
interim17
marked this pull request as draft
July 27, 2026 20:36
interim17
commented
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]), | ||
| ); | ||
| } | ||
|
|
Contributor
Author
There was a problem hiding this comment.
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.
… for preview rendering in the idea post template
…l/idea-board into idea-preview-post-leave
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
fieldsMetaDatachannel, 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.