@cmssy/next 0.1.0 → 0.1.2
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/README.md +64 -0
- package/dist/index.cjs +3 -1
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -1
- package/package.json +18 -3
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/dist/index.cjs
CHANGED
|
@@ -96,6 +96,7 @@ function createCmssyPage(config, blocks, options) {
|
|
|
96
96
|
page,
|
|
97
97
|
locale,
|
|
98
98
|
defaultLocale,
|
|
99
|
+
enabledLocales: config.enabledLocales,
|
|
99
100
|
edit: { editorOrigin: bridgeOrigin }
|
|
100
101
|
}
|
|
101
102
|
);
|
|
@@ -106,7 +107,8 @@ function createCmssyPage(config, blocks, options) {
|
|
|
106
107
|
page,
|
|
107
108
|
blocks,
|
|
108
109
|
locale,
|
|
109
|
-
defaultLocale
|
|
110
|
+
defaultLocale,
|
|
111
|
+
enabledLocales: config.enabledLocales
|
|
110
112
|
}
|
|
111
113
|
);
|
|
112
114
|
};
|
package/dist/index.d.cts
CHANGED
|
@@ -9,6 +9,8 @@ interface CmssyNextConfig {
|
|
|
9
9
|
draftSecret: string;
|
|
10
10
|
editorOrigin: string | string[];
|
|
11
11
|
defaultLocale?: string;
|
|
12
|
+
/** All languages enabled on the workspace; exposed to blocks via context.locale.enabled. */
|
|
13
|
+
enabledLocales?: string[];
|
|
12
14
|
resolveLocale?: () => string | Promise<string>;
|
|
13
15
|
}
|
|
14
16
|
|
|
@@ -16,6 +18,7 @@ interface CmssyEditorProps {
|
|
|
16
18
|
page: CmssyPageData;
|
|
17
19
|
locale: string;
|
|
18
20
|
defaultLocale: string;
|
|
21
|
+
enabledLocales?: string[];
|
|
19
22
|
edit: EditBridgeConfig;
|
|
20
23
|
}
|
|
21
24
|
interface CreateCmssyPageOptions {
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ interface CmssyNextConfig {
|
|
|
9
9
|
draftSecret: string;
|
|
10
10
|
editorOrigin: string | string[];
|
|
11
11
|
defaultLocale?: string;
|
|
12
|
+
/** All languages enabled on the workspace; exposed to blocks via context.locale.enabled. */
|
|
13
|
+
enabledLocales?: string[];
|
|
12
14
|
resolveLocale?: () => string | Promise<string>;
|
|
13
15
|
}
|
|
14
16
|
|
|
@@ -16,6 +18,7 @@ interface CmssyEditorProps {
|
|
|
16
18
|
page: CmssyPageData;
|
|
17
19
|
locale: string;
|
|
18
20
|
defaultLocale: string;
|
|
21
|
+
enabledLocales?: string[];
|
|
19
22
|
edit: EditBridgeConfig;
|
|
20
23
|
}
|
|
21
24
|
interface CreateCmssyPageOptions {
|
package/dist/index.js
CHANGED
|
@@ -94,6 +94,7 @@ function createCmssyPage(config, blocks, options) {
|
|
|
94
94
|
page,
|
|
95
95
|
locale,
|
|
96
96
|
defaultLocale,
|
|
97
|
+
enabledLocales: config.enabledLocales,
|
|
97
98
|
edit: { editorOrigin: bridgeOrigin }
|
|
98
99
|
}
|
|
99
100
|
);
|
|
@@ -104,7 +105,8 @@ function createCmssyPage(config, blocks, options) {
|
|
|
104
105
|
page,
|
|
105
106
|
blocks,
|
|
106
107
|
locale,
|
|
107
|
-
defaultLocale
|
|
108
|
+
defaultLocale,
|
|
109
|
+
enabledLocales: config.enabledLocales
|
|
108
110
|
}
|
|
109
111
|
);
|
|
110
112
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmssy/next",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
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": {
|
|
@@ -21,7 +36,7 @@
|
|
|
21
36
|
"dist"
|
|
22
37
|
],
|
|
23
38
|
"peerDependencies": {
|
|
24
|
-
"@cmssy/react": "^0.1.
|
|
39
|
+
"@cmssy/react": "^0.1.2",
|
|
25
40
|
"next": ">=15",
|
|
26
41
|
"react": "^18.2.0 || ^19.0.0",
|
|
27
42
|
"react-dom": "^18.2.0 || ^19.0.0"
|
|
@@ -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.
|
|
52
|
+
"@cmssy/react": "0.1.2"
|
|
38
53
|
},
|
|
39
54
|
"scripts": {
|
|
40
55
|
"build": "tsup",
|