@dispatchcms/next 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
 
2
2
  
3
- > @dispatchcms/next@0.0.4 build /Users/jamescalmus/Documents/dispatch/packages/next
3
+ > @dispatchcms/next@0.0.5 build /Users/jamescalmus/Documents/dispatch/packages/next
4
4
  > tsup
5
5
 
6
6
  CLI Building entry: src/index.ts
@@ -11,13 +11,13 @@
11
11
  CLI Cleaning output folder
12
12
  CJS Build start
13
13
  ESM Build start
14
- ESM dist/index.mjs 2.04 KB
15
- ESM dist/index.mjs.map 4.20 KB
16
- ESM ⚡️ Build success in 7ms
17
14
  CJS dist/index.js 3.18 KB
18
15
  CJS dist/index.js.map 4.45 KB
19
- CJS ⚡️ Build success in 7ms
16
+ CJS ⚡️ Build success in 13ms
17
+ ESM dist/index.mjs 2.04 KB
18
+ ESM dist/index.mjs.map 4.20 KB
19
+ ESM ⚡️ Build success in 13ms
20
20
  DTS Build start
21
- DTS ⚡️ Build success in 329ms
21
+ DTS ⚡️ Build success in 365ms
22
22
  DTS dist/index.d.ts 938.00 B
23
23
  DTS dist/index.d.mts 938.00 B
package/README.md CHANGED
@@ -65,11 +65,20 @@ Returns a single post by its preview token (draft or published). Use this in you
65
65
 
66
66
  Exportable types:
67
67
 
68
- - **`Post`** – A post from the CMS. Main fields: `id`, `title`, `slug`, `content` (TipTap JSON), `excerpt`, `featured_image`, `published`, `published_at`, `created_at`, `updated_at`, `site_id`.
68
+ - **`Post`** – A post from the CMS. Main fields: `id`, `title`, `slug`, `content` (TipTap/ProseMirror JSON), `excerpt`, `featured_image`, `published`, `published_at`, `created_at`, `updated_at`, `site_id`. See **Rendering content** below for how to render `content`.
69
69
  - **`DispatchConfig`** – Options for `initDispatch`: `{ siteKey: string }`.
70
70
 
71
71
  Use your editor’s type hints or the generated `.d.ts` for the full shape.
72
72
 
73
+ ## Rendering content
74
+
75
+ Post `content` is TipTap (ProseMirror) JSON. Render it with TipTap’s static renderer so formatting, links, and images match the CMS:
76
+
77
+ - **Server Components:** Use `renderToHTMLString` from `@tiptap/static-renderer/pm/html-string` with the same extensions as the CMS (e.g. Document, Paragraph, Heading, Bold, Italic, Blockquote, BulletList, ListItem, Link, Image), then render the HTML in a wrapper `div` (the output is safe TipTap-generated HTML).
78
+ - **Client:** Use `renderToReactElement` from `@tiptap/static-renderer/pm/react` for a React node with no `dangerouslySetInnerHTML`.
79
+
80
+ Use the same extensions as the CMS editor for full parity. See [TipTap static renderer docs](https://tiptap.dev/docs/editor/api/utilities/static-renderer).
81
+
73
82
  ## Example (Next.js App Router)
74
83
 
75
84
  **List posts (Server Component):**
@@ -106,7 +115,7 @@ export default async function PostPage({ params }: { params: { slug: string } })
106
115
  <article>
107
116
  <h1>{post.title}</h1>
108
117
  {post.excerpt && <p>{post.excerpt}</p>}
109
- {/* Render post.content (TipTap JSON) with your editor/renderer */}
118
+ {/* Render post.content with TipTap: renderToHTMLString(extensions, post.content) then a div, or use renderToReactElement in a client component */}
110
119
  </article>
111
120
  );
112
121
  }
@@ -137,7 +146,7 @@ export default async function PreviewPage({
137
146
  <p className="text-sm text-muted-foreground">Preview</p>
138
147
  <h1>{post.title}</h1>
139
148
  {post.excerpt && <p>{post.excerpt}</p>}
140
- {/* Render post.content the same way as your live post page */}
149
+ {/* Render post.content with TipTap (same as your live post page) */}
141
150
  </article>
142
151
  );
143
152
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dispatchcms/next",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Fetch published posts from a Dispatch CMS in Next.js",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",