@cmssy/next 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/README.md +64 -0
  2. package/package.json +17 -2
package/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # @cmssy/next
2
+
3
+ Next.js (App Router) bindings for a [cmssy](https://cmssy.com) headless site.
4
+ One catch-all route renders your published cmssy content with local block
5
+ components, with live edit-mode preview built in. Pairs with
6
+ [`@cmssy/react`](https://www.npmjs.com/package/@cmssy/react) (blocks + data).
7
+
8
+ ```bash
9
+ pnpm add @cmssy/next @cmssy/react
10
+ ```
11
+
12
+ ## Render every page
13
+
14
+ ```tsx
15
+ // app/[[...path]]/page.tsx
16
+ import { createCmssyPage } from "@cmssy/next";
17
+ import { cmssy } from "@/cmssy/config";
18
+ import { blocks } from "@/cmssy/blocks";
19
+ import { CmssyEditor } from "@/cmssy/editor";
20
+
21
+ export default createCmssyPage(cmssy, blocks, { editor: CmssyEditor });
22
+ ```
23
+
24
+ ```ts
25
+ // cmssy/config.ts
26
+ import type { CmssyNextConfig } from "@cmssy/next";
27
+
28
+ export const cmssy: CmssyNextConfig = {
29
+ apiUrl: process.env.CMSSY_API_URL ?? "", // public GraphQL delivery endpoint
30
+ workspaceSlug: process.env.CMSSY_WORKSPACE_SLUG ?? "",
31
+ draftSecret: process.env.CMSSY_DRAFT_SECRET ?? "", // edit-mode preview handshake
32
+ editorOrigin: process.env.CMSSY_EDITOR_ORIGIN ?? "", // only needed in edit mode
33
+ defaultLocale: "en",
34
+ };
35
+ ```
36
+
37
+ `createCmssyPage` fetches the page for the request path and renders it. In edit
38
+ mode (draft cookie or `?cmssyEdit=1`) it renders your `editor` instead and frames
39
+ the live-edit bridge. A published build does **not** require `editorOrigin`.
40
+
41
+ ## Draft preview
42
+
43
+ ```ts
44
+ // app/api/draft/route.ts
45
+ import { createDraftRoute } from "@cmssy/next";
46
+ export const GET = createDraftRoute(cmssy);
47
+ ```
48
+
49
+ ## Edit-mode CSP
50
+
51
+ ```ts
52
+ import { cmssyCspHeaders, applyCmssyCsp } from "@cmssy/next";
53
+ ```
54
+
55
+ Helpers to frame the page inside the cmssy editor only in edit mode.
56
+
57
+ ## Exports
58
+
59
+ `createCmssyPage`, `createDraftRoute`, `cmssyCspHeaders` / `applyCmssyCsp`,
60
+ `isCmssyEditRequest` / `isCmssyEditMode`, and the `CmssyNextConfig` type.
61
+
62
+ ## License
63
+
64
+ MIT
package/package.json CHANGED
@@ -1,6 +1,21 @@
1
1
  {
2
2
  "name": "@cmssy/next",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
+ "description": "Next.js App Router bindings for cmssy headless sites (createCmssyPage + draft preview)",
5
+ "keywords": [
6
+ "cmssy",
7
+ "cms",
8
+ "headless",
9
+ "nextjs",
10
+ "next",
11
+ "app-router"
12
+ ],
13
+ "homepage": "https://cmssy.com",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/cmssy-io/cmssy-sdk.git",
17
+ "directory": "packages/next"
18
+ },
4
19
  "type": "module",
5
20
  "license": "MIT",
6
21
  "publishConfig": {
@@ -34,7 +49,7 @@
34
49
  "tsup": "^8.3.0",
35
50
  "typescript": "^5.6.0",
36
51
  "vitest": "^2.1.0",
37
- "@cmssy/react": "0.1.0"
52
+ "@cmssy/react": "0.1.1"
38
53
  },
39
54
  "scripts": {
40
55
  "build": "tsup",