Opentferreira wants to merge 3 commits into main from feature/live-draft-preview· opened 3 days ago
+62−16
tferreira commented 3 days agoAuthor
Why
Editors keep publishing just to see how a post looks, then unpublishing. This adds a live preview.
What
/blog/<slug>?preview=1 renders the latest draft from the CMS and polls every 3s, so editors can
keep it open next to the CMS editor while they type
getPost takes a draft option (uncached) and now encodes the slug
CMS env vars are now NEXT_PUBLIC_CMS_URL / NEXT_PUBLIC_CMS_TOKEN so the preview can fetch from the
browser (updated in Vercel for all environments)
Revalidate webhook now only busts the post that changed instead of the whole blog, and accepts the
secret as ?secret= because the new CMS webhook UI cannot set custom headers
Testing
Opened a draft with ?preview=1, edited it in the CMS, preview picked it up after a few seconds.
Why
Editors keep publishing just to see how a post looks, then unpublishing. This adds a live preview.
What
/blog/<slug>?preview=1renders the latest draft from the CMS and polls every 3s, so editors can keep it open next to the CMS editor while they typegetPosttakes adraftoption (uncached) and now encodes the slugNEXT_PUBLIC_CMS_URL/NEXT_PUBLIC_CMS_TOKENso the preview can fetch from the browser (updated in Vercel for all environments)?secret=because the new CMS webhook UI cannot set custom headersTesting
Opened a draft with
?preview=1, edited it in the CMS, preview picked it up after a few seconds.