Live draft preview for blog posts #502

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.

tferreira added 3 commits 3 days ago
Add draft option to getPost5dfe352
Add LivePreview client component5efe36b
Scope revalidation to the edited post5bfe320

Review required

Review the changes, then submit to get graded.

Some checks haven’t completed yet

1 check: dojo / review-grader

Keyboard shortcuts

Site-wide

Focus the search bar
/
Show this dialog
?

Pull request

Move to the next file
j
Move to the previous file
k
Filter changed files
t
Comment on the selected lines
c
Select a range of lines
Shiftclick