@cmssy/next 19.27.0 → 19.28.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.
- package/README.md +43 -24
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ pnpm add @cmssy/next @cmssy/react
|
|
|
13
13
|
|
|
14
14
|
```tsx
|
|
15
15
|
// app/[[...path]]/page.tsx
|
|
16
|
-
import { createCmssyPage } from "@cmssy/next";
|
|
16
|
+
import { createCmssyPage } from "@cmssy/next/server";
|
|
17
17
|
import { cmssy } from "@/cmssy/config";
|
|
18
18
|
import { blocks } from "@/cmssy/blocks";
|
|
19
19
|
import { CmssyEditor } from "@/cmssy/editor";
|
|
@@ -37,9 +37,43 @@ export const cmssy = defineCmssyConfig({
|
|
|
37
37
|
});
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
`createCmssyPage` fetches the page for the request path and renders
|
|
41
|
-
|
|
42
|
-
the
|
|
40
|
+
`createCmssyPage` fetches the published page for the request path and renders
|
|
41
|
+
it; an unpublished page answers 404. It does not handle the editor - that needs
|
|
42
|
+
the edit route and proxy below. A published build does **not** require
|
|
43
|
+
`editorOrigin`.
|
|
44
|
+
|
|
45
|
+
## Let the editor frame your site
|
|
46
|
+
|
|
47
|
+
The cmssy editor frames the page's own URL with
|
|
48
|
+
`?cmssyEdit=1&cmssySecret=<draft secret>`. The proxy verifies the secret and
|
|
49
|
+
rewrites that request to `/cmssy-edit/...`, which renders draft content with
|
|
50
|
+
your `editor`. Both files are required; without them the editor reports that
|
|
51
|
+
the preview did not respond.
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
// app/cmssy-edit/[[...path]]/page.tsx
|
|
55
|
+
import { createCmssyEditPage } from "@cmssy/next/server";
|
|
56
|
+
import { cmssy } from "@/cmssy/config";
|
|
57
|
+
import { blocks } from "@/cmssy/blocks";
|
|
58
|
+
import { CmssyEditor } from "@/cmssy/editor";
|
|
59
|
+
|
|
60
|
+
export const dynamic = "force-dynamic";
|
|
61
|
+
|
|
62
|
+
export default createCmssyEditPage(cmssy, blocks, { editor: CmssyEditor });
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
// proxy.ts (Next.js 16) - on Next.js 15 name it middleware.ts and export `middleware`
|
|
67
|
+
import { createCmssyProxy } from "@cmssy/next/middleware";
|
|
68
|
+
import { cmssy } from "@/cmssy/config";
|
|
69
|
+
|
|
70
|
+
export const proxy = createCmssyProxy(cmssy);
|
|
71
|
+
export const config = { matcher: ["/((?!_next/|api/|.*\\..*).*)"] };
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
`proxy.ts` sits next to `app/` (in `src/` when the app is `src/app`). Set the
|
|
75
|
+
workspace preview URL to the exact deployed origin, e.g.
|
|
76
|
+
`https://my-site.vercel.app`.
|
|
43
77
|
|
|
44
78
|
## Draft preview
|
|
45
79
|
|
|
@@ -70,11 +104,9 @@ webhook. Draft mode and the editor always read live.
|
|
|
70
104
|
|
|
71
105
|
## Edit-mode CSP
|
|
72
106
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
Helpers to frame the page inside the cmssy editor only in edit mode.
|
|
107
|
+
`createCmssyProxy` already sets it on editor requests. For a hand-written proxy,
|
|
108
|
+
`applyCmssyCsp(response, { editorOrigin: cmssy.editorOrigin })` from
|
|
109
|
+
`@cmssy/next/middleware` lets the cmssy editor frame the response.
|
|
78
110
|
|
|
79
111
|
## Localized navigation (path prefix)
|
|
80
112
|
|
|
@@ -91,21 +123,8 @@ import { localizeHref } from "@cmssy/next";
|
|
|
91
123
|
<Link href={localizeHref("/about", locale)}>About</Link>; // → /en/about while EN is active
|
|
92
124
|
```
|
|
93
125
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
middleware convention); on Next.js 15 use `middleware.ts` with the same body.
|
|
97
|
-
|
|
98
|
-
```ts
|
|
99
|
-
// proxy.ts (Next.js 16) — or middleware.ts on Next.js 15
|
|
100
|
-
import { createCmssyLocaleMiddleware } from "@cmssy/next";
|
|
101
|
-
import { cmssy } from "@/cmssy/config";
|
|
102
|
-
|
|
103
|
-
export const proxy = createCmssyLocaleMiddleware(cmssy);
|
|
104
|
-
export const config = { matcher: ["/((?!_next/|api/|.*\\..*).*)"] };
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
On Next.js 15, name the file `middleware.ts` and rename the export to
|
|
108
|
-
`middleware` (`export const middleware = createCmssyLocaleMiddleware(cmssy)`).
|
|
126
|
+
The root layout can't read the path, so the proxy resolves the locale from the
|
|
127
|
+
path prefix: the `createCmssyProxy` from the editor section already does it.
|
|
109
128
|
|
|
110
129
|
`localizeHref(href, locale)` and the `CMSSY_LOCALE_HEADER` constant are
|
|
111
130
|
re-exported from `@cmssy/next` (and `@cmssy/core`).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmssy/next",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.28.1",
|
|
4
4
|
"description": "Next.js App Router bindings for cmssy headless sites (createCmssyPage + draft preview)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cmssy",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"dist"
|
|
72
72
|
],
|
|
73
73
|
"peerDependencies": {
|
|
74
|
-
"@cmssy/react": "^19.
|
|
74
|
+
"@cmssy/react": "^19.28.1",
|
|
75
75
|
"next": ">=15",
|
|
76
76
|
"react": "^18.2.0 || ^19.0.0",
|
|
77
77
|
"react-dom": "^18.2.0 || ^19.0.0"
|
|
@@ -85,12 +85,12 @@
|
|
|
85
85
|
"tsup": "^8.3.0",
|
|
86
86
|
"typescript": "^5.6.0",
|
|
87
87
|
"vitest": "^2.1.0",
|
|
88
|
-
"@cmssy/react": "19.
|
|
88
|
+
"@cmssy/react": "19.28.1"
|
|
89
89
|
},
|
|
90
90
|
"dependencies": {
|
|
91
91
|
"@cmssy/types": "0.72.0",
|
|
92
92
|
"server-only": "^0.0.1",
|
|
93
|
-
"@cmssy/core": "19.
|
|
93
|
+
"@cmssy/core": "19.28.1"
|
|
94
94
|
},
|
|
95
95
|
"scripts": {
|
|
96
96
|
"build": "tsup",
|