Skip to content
agent-cms

Components / cms-preview-comments

Preview comments

For your public page when it shows a draft through a preview link made with "Allow comments": the comments on the draft and a box for someone without an account to add one. Needs no provider.

With the shadcn CLI

npx shadcn add https://agent-cms-docs.vercel.app/r/cms-preview-comments.json

With the agent-cms CLI

npx @mainsoft/agent-cms add cms-preview-comments

This box goes on your public page. In the editor demo, make a preview link with "Allow comments": the page behind that link is yours, so the demo has none. Open the editor demo

Usage#

tsx
// app/posts/[slug]/page.tsx (your public page)
import { CmsPreviewComments } from "@/components/cms/cms-preview-comments";

const preview = token ? await cms.readPreview(token) : null;
// ...
{preview?.comments ? <CmsPreviewComments token={token} /> : null}

It needs no CmsProvider: the token is the permission. baseUrl is where the CMS route is mounted (/api/cms by default), and messages takes the Korean strings (import { ko } from "@/components/cms/cms-messages"). The link stops working when it expires, and so does the box.

note

On npm from 0.10.0. This docs site uses it: a preview link from its own editor opens the draft page with this box under the text.