Preview Ideas in CMS (pt. 1/2) - #112
Conversation
✅ Deploy Preview for project-idea-board ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
| authors, | ||
| date, | ||
| introduction, | ||
| isPreview, |
There was a problem hiding this comment.
I don't love these isPreview checks, and kind of wish that the gatsby components didn't need to know anything about the Decap previews, but it's probably a worthwhile tradeoff, since designing to avoid it would force bigger changes (or make previews onerous to maintain).
As far as gatsby is concerned this is just some visual noise since isPreview should never be true outside of Decap.
| : new Date(rawDate as string | number).toLocaleDateString("en-US", { | ||
| year: "numeric", | ||
| month: "long", | ||
| day: "2-digit", |
There was a problem hiding this comment.
nit: maybe add timeZone: "UTC" here to avoid cases where Aug 10 locally is already Aug 11 in UTC
| ): Partial<IdeaPostTemplateProps> { | ||
| const v = raw as Partial<IdeaPostTemplateProps>; | ||
|
|
||
| // program: single select string → array |
There was a problem hiding this comment.
non-blocking, but worth noting down: this comment made me go look at how program is setup in config.yml, and turns out it doesn't have a multiple: true. Returning a string when the select is single is totally the right thing to do here for the preview. but more importantly though, we should add multiple:true to program if we allow multiple selections in the admin site
| CMS.registerPreviewTemplate("index", IndexPagePreview); | ||
| CMS.registerPreviewTemplate("about", AboutPagePreview); | ||
| CMS.registerPreviewTemplate("idea", IdeaPostPreview); | ||
| CMS.registerPreviewTemplate("ideas", IdeaPostPreview); |
Problem
Advances #87 Advances #55
We have no customized preview for idea pages.
Solution
Now we have a much improved preview with relevant styling, and a few workarounds that need improvement over time.
I split this work into two PRs to make review simpler, this and #111 should be merged together.
In part one:
cms.jshad a typo ("idea" vs "ideas") so old preview component wasn't registering at all.Some workarounds:
isPreviewstate in the Gatsby template helps guard for cases where we can't use Gatsby components (likeLink) or consume the data layer (likeStaticQueryin child components).What we don't get: