@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.
- package/.turbo/turbo-build.log +6 -6
- package/README.md +12 -3
- package/package.json +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @dispatchcms/next@0.0.
|
|
3
|
+
> @dispatchcms/next@0.0.5 build /Users/jamescalmus/Documents/dispatch/packages/next
|
|
4
4
|
> tsup
|
|
5
5
|
|
|
6
6
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
[34mCLI[39m Cleaning output folder
|
|
12
12
|
[34mCJS[39m Build start
|
|
13
13
|
[34mESM[39m Build start
|
|
14
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m2.04 KB[39m
|
|
15
|
-
[32mESM[39m [1mdist/index.mjs.map [22m[32m4.20 KB[39m
|
|
16
|
-
[32mESM[39m ⚡️ Build success in 7ms
|
|
17
14
|
[32mCJS[39m [1mdist/index.js [22m[32m3.18 KB[39m
|
|
18
15
|
[32mCJS[39m [1mdist/index.js.map [22m[32m4.45 KB[39m
|
|
19
|
-
[32mCJS[39m ⚡️ Build success in
|
|
16
|
+
[32mCJS[39m ⚡️ Build success in 13ms
|
|
17
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m2.04 KB[39m
|
|
18
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m4.20 KB[39m
|
|
19
|
+
[32mESM[39m ⚡️ Build success in 13ms
|
|
20
20
|
DTS Build start
|
|
21
|
-
DTS ⚡️ Build success in
|
|
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
|
|
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
|
|
149
|
+
{/* Render post.content with TipTap (same as your live post page) */}
|
|
141
150
|
</article>
|
|
142
151
|
);
|
|
143
152
|
}
|