feat(cms): add live preview for pages and posts#418
Conversation
closed cod-377
|
|
|
View your CI Pipeline Execution ↗ for commit bc2dbf6
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Pull request overview
Adds Payload CMS live preview support to the CMS Next.js app so editors can see real-time updates for pages and posts in the admin preview panel.
Changes:
- Add
@payloadcms/live-preview-reactdependency. - Configure
admin.livePreviewinapps/cms/src/payload.config.ts(breakpoints + URL resolver for pages/posts). - Introduce client live preview components (
LivePreview.client.tsxand per-route*-preview.client.tsxwrappers) and wire them into the RSC routes.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Locks the added live preview dependency and its transitive deps. |
| package.json | Adds @payloadcms/live-preview-react dependency. |
| apps/cms/src/payload.config.ts | Enables/admin-configures live preview (breakpoints, collections, URL mapping). |
| apps/cms/src/components/RefreshRouteOnSave.tsx | Adds a client component wrapper for “refresh on save” live preview (currently unused). |
| apps/cms/src/components/LivePreview.client.tsx | Adds a generic client wrapper around useLivePreview using PayloadProvider context. |
| apps/cms/src/app/(site)/posts/[...slug]/post-preview.client.tsx | Client boundary to live-preview posts. |
| apps/cms/src/app/(site)/posts/[...slug]/page.tsx | Switches post rendering to use the live preview client boundary. |
| apps/cms/src/app/(site)/page.tsx | Switches landing page rendering to use the live preview client boundary. |
| apps/cms/src/app/(site)/landing-page-preview.client.tsx | Client boundary to live-preview the landing page. |
| apps/cms/src/app/(site)/[...slug]/page.tsx | Switches page rendering to use the live preview client boundary. |
| apps/cms/src/app/(site)/[...slug]/page-preview.client.tsx | Client boundary to live-preview pages (threads through pre-fetched blocksData). |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
✨ Your pull request project is ready for preview
|
|
✨ Your pull request projects are ready for preview
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #418 +/- ##
==========================================
+ Coverage 64.04% 64.19% +0.15%
==========================================
Files 199 207 +8
Lines 5270 5348 +78
Branches 716 735 +19
==========================================
+ Hits 3375 3433 +58
- Misses 1856 1865 +9
- Partials 39 50 +11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
@payloadcms/live-preview-reactdependencyadmin.livePreviewinpayload.config.tswith mobile/tablet/desktop breakpoints, scoped topagesandposts; URL function routes pages to/{slug}and posts to/posts/{slug}LivePreview.client.tsxcomponent that wrapsuseLivePreview— centralises the hook call and readsserverURLfromPayloadProvidercontext*-preview.client.tsxwrappers for landing page, pages, and posts; each is a thin render-function client boundary used by the RSC page componentsPREVIEW_URLenv var (falls back toserverURL; set to the web client URL when running in host mode)Notes
useLivePreviewapproach rather thanRefreshRouteOnSave; the server-side approach requires autosave/versions to show unsaved changes, which is planned for the next issueRefreshRouteOnSaveis included as a reference but unused — will be revisited when versions/drafts/autosave landsTest plan
🤖 Generated with Claude Code