@cmssy/cli 12.14.1 → 13.0.0

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.
@@ -5,11 +5,13 @@ import {
5
5
  type CmssyLayoutGroup,
6
6
  } from "@cmssy/react";
7
7
  import { CmssyLazyLayout } from "@cmssy/react/client";
8
+ import type { CmssyRegion } from "@cmssy/astro";
9
+ import type { layout } from "../cmssy.config";
8
10
  import { blocks } from "./blocks";
9
11
 
10
12
  export interface LayoutSlotProps {
11
13
  groups: CmssyLayoutGroup[];
12
- position: "header" | "footer";
14
+ position: CmssyRegion<typeof layout>;
13
15
  locale: string;
14
16
  defaultLocale: string;
15
17
  enabledLocales: string[];
@@ -63,6 +65,8 @@ export default function LayoutSlot({
63
65
  locale={locale}
64
66
  defaultLocale={defaultLocale}
65
67
  context={context}
68
+ resolvedContent={resolvedContent?.[block.id]}
69
+ data={data?.[block.id]}
66
70
  />
67
71
  ))}
68
72
  </>
@@ -1,7 +1,15 @@
1
- import { defineCmssyConfig } from "@cmssy/astro";
1
+ import { defineCmssyConfig, defineCmssyLayout } from "@cmssy/astro";
2
+
3
+ export const layout = defineCmssyLayout({
4
+ regions: [
5
+ { id: "header", label: "Header" },
6
+ { id: "footer", label: "Footer" },
7
+ ],
8
+ });
2
9
 
3
10
  export const cmssy = defineCmssyConfig({
4
11
  org: process.env.CMSSY_ORG_SLUG,
5
12
  workspaceSlug: process.env.CMSSY_WORKSPACE_SLUG,
6
13
  draftSecret: process.env.CMSSY_DRAFT_SECRET,
14
+ layout,
7
15
  });
@@ -1,6 +1,9 @@
1
1
  ---
2
2
  import { loadCmssyPage } from "@cmssy/astro";
3
- import { resolveEditorBlockData } from "@cmssy/react";
3
+ import {
4
+ resolveEditorBlockData,
5
+ resolveEditorLayoutBlockData,
6
+ } from "@cmssy/react";
4
7
  import { cmssy } from "../cmssy.config";
5
8
  import { blocks } from "../cmssy/blocks";
6
9
  import { Blocks } from "../components/Blocks";
@@ -27,6 +30,19 @@ const { data: blockData, content: blockContent } = await resolveEditorBlockData(
27
30
  enabledLocales,
28
31
  config: cmssy,
29
32
  });
33
+
34
+ const layoutSlot = {
35
+ groups: layouts,
36
+ blocks,
37
+ locale,
38
+ defaultLocale,
39
+ enabledLocales,
40
+ config: cmssy,
41
+ };
42
+ const [header, footer] = await Promise.all([
43
+ resolveEditorLayoutBlockData({ ...layoutSlot, position: "header" }),
44
+ resolveEditorLayoutBlockData({ ...layoutSlot, position: "footer" }),
45
+ ]);
30
46
  ---
31
47
 
32
48
  <html lang={locale}>
@@ -41,6 +57,8 @@ const { data: blockData, content: blockContent } = await resolveEditorBlockData(
41
57
  locale={locale}
42
58
  defaultLocale={defaultLocale}
43
59
  enabledLocales={enabledLocales}
60
+ data={header.data}
61
+ resolvedContent={header.content}
44
62
  />
45
63
  {
46
64
  page ? (
@@ -62,6 +80,8 @@ const { data: blockData, content: blockContent } = await resolveEditorBlockData(
62
80
  locale={locale}
63
81
  defaultLocale={defaultLocale}
64
82
  enabledLocales={enabledLocales}
83
+ data={footer.data}
84
+ resolvedContent={footer.content}
65
85
  />
66
86
  </body>
67
87
  </html>
@@ -7,8 +7,15 @@ import LayoutSlot from "../../cmssy/layout-slot";
7
7
 
8
8
  export const prerender = false;
9
9
 
10
- const { page, layouts, locale, defaultLocale, enabledLocales, editorData } =
11
- await loadCmssyPage(cmssy, Astro.request, Astro.url, { blocks });
10
+ const {
11
+ page,
12
+ layouts,
13
+ locale,
14
+ defaultLocale,
15
+ enabledLocales,
16
+ editorData,
17
+ layoutRegions,
18
+ } = await loadCmssyPage(cmssy, Astro.request, Astro.url, { blocks });
12
19
  const editorOrigin = resolveEditorOrigin(cmssy.editorOrigin);
13
20
  ---
14
21
 
@@ -35,7 +42,7 @@ const editorOrigin = resolveEditorOrigin(cmssy.editorOrigin);
35
42
  locale={locale}
36
43
  defaultLocale={defaultLocale}
37
44
  enabledLocales={enabledLocales}
38
- edit={{ editorOrigin }}
45
+ edit={{ editorOrigin, layoutRegions }}
39
46
  />
40
47
  <LayoutSlot
41
48
  client:load
@@ -1,5 +1,6 @@
1
1
  import { createCmssyPage, CmssyLayoutSlot } from "@cmssy/next/server";
2
- import { cmssy } from "@/cmssy.config";
2
+ import type { CmssyRegion } from "@cmssy/next";
3
+ import { cmssy, type layout } from "@/cmssy.config";
3
4
  import { blocks } from "@/cmssy/blocks";
4
5
  import { CmssyEditor } from "@/cmssy/editor";
5
6
  import { EditableLayout } from "@/cmssy/editable-layout";
@@ -21,7 +22,7 @@ const CmssyPage = createCmssyPage(cmssy, blocks, { editor: CmssyEditor });
21
22
 
22
23
  export default async function Page(props: PageProps) {
23
24
  const { path } = await props.params;
24
- const slot = (position: "header" | "footer") => (
25
+ const slot = (position: CmssyRegion<typeof layout>) => (
25
26
  <CmssyLayoutSlot
26
27
  config={cmssy}
27
28
  blocks={blocks}
@@ -3,7 +3,8 @@ import {
3
3
  CmssyLayoutSlot,
4
4
  isCmssyEditMode,
5
5
  } from "@cmssy/next/server";
6
- import { cmssy } from "@/cmssy.config";
6
+ import type { CmssyRegion } from "@cmssy/next";
7
+ import { cmssy, type layout } from "@/cmssy.config";
7
8
  import { blocks } from "@/cmssy/blocks";
8
9
  import { CmssyEditor } from "@/cmssy/editor";
9
10
  import { EditableLayout } from "@/cmssy/editable-layout";
@@ -24,7 +25,7 @@ export default async function EditPage(props: PageProps) {
24
25
 
25
26
  const editMode = await isCmssyEditMode();
26
27
 
27
- const slot = (position: "header" | "footer") => (
28
+ const slot = (position: CmssyRegion<typeof layout>) => (
28
29
  <CmssyLayoutSlot
29
30
  config={cmssy}
30
31
  blocks={blocks}
@@ -1,7 +1,15 @@
1
- import { defineCmssyConfig } from "@cmssy/next";
1
+ import { defineCmssyConfig, defineCmssyLayout } from "@cmssy/next";
2
+
3
+ export const layout = defineCmssyLayout({
4
+ regions: [
5
+ { id: "header", label: "Header" },
6
+ { id: "footer", label: "Footer" },
7
+ ],
8
+ });
2
9
 
3
10
  export const cmssy = defineCmssyConfig({
4
11
  org: process.env.CMSSY_ORG_SLUG,
5
12
  workspaceSlug: process.env.CMSSY_WORKSPACE_SLUG,
6
13
  draftSecret: process.env.CMSSY_DRAFT_SECRET,
14
+ layout,
7
15
  });
@@ -1,4 +1,4 @@
1
- import { CmssyLazyEditor } from "@cmssy/react/client";
1
+ import { CmssyLazyEditor, type EditBridgeConfig } from "@cmssy/react/client";
2
2
  import type { CmssyPageData } from "@cmssy/core";
3
3
 
4
4
  export function CmssyEditor(props: {
@@ -6,7 +6,7 @@ export function CmssyEditor(props: {
6
6
  locale: string;
7
7
  defaultLocale: string;
8
8
  enabledLocales: string[];
9
- edit: { editorOrigin: string | string[] };
9
+ edit: EditBridgeConfig;
10
10
  }) {
11
11
  return <CmssyLazyEditor {...props} load={() => import("./blocks")} />;
12
12
  }
@@ -5,11 +5,13 @@ import {
5
5
  type CmssyLayoutGroup,
6
6
  } from "@cmssy/react";
7
7
  import { CmssyLazyLayout } from "@cmssy/react/client";
8
+ import type { CmssyRegion } from "@cmssy/remix";
9
+ import type { layout } from "../../cmssy.config";
8
10
  import { blocks } from "./blocks";
9
11
 
10
12
  export interface LayoutSlotProps {
11
13
  groups: CmssyLayoutGroup[];
12
- position: "header" | "footer";
14
+ position: CmssyRegion<typeof layout>;
13
15
  locale: string;
14
16
  defaultLocale: string;
15
17
  enabledLocales: string[];
@@ -63,6 +65,8 @@ export function LayoutSlot({
63
65
  locale={locale}
64
66
  defaultLocale={defaultLocale}
65
67
  context={context}
68
+ resolvedContent={resolvedContent?.[block.id]}
69
+ data={data?.[block.id]}
66
70
  />
67
71
  ))}
68
72
  </>
@@ -3,10 +3,16 @@ import {
3
3
  buildBlockContext,
4
4
  buildBlockMap,
5
5
  resolveEditorBlockData,
6
+ resolveEditorLayoutBlockData,
6
7
  type EditorBlockData,
8
+ type ResolveLayoutBlockDataOptions,
7
9
  } from "@cmssy/react";
8
- import { createCmssyHeaders, createCmssyLoader } from "@cmssy/remix";
9
- import { cmssy } from "../../cmssy.config";
10
+ import {
11
+ createCmssyHeaders,
12
+ createCmssyLoader,
13
+ type CmssyRegion,
14
+ } from "@cmssy/remix";
15
+ import { cmssy, type layout } from "../../cmssy.config";
10
16
  import { blocks } from "../cmssy/blocks";
11
17
  import { CmssyEditor } from "../cmssy/editor";
12
18
  import { LayoutSlot } from "../cmssy/layout-slot";
@@ -14,6 +20,16 @@ import type { Route } from "./+types/page";
14
20
 
15
21
  const cmssyLoader = createCmssyLoader(cmssy, { blocks });
16
22
 
23
+ type Position = CmssyRegion<typeof layout>;
24
+
25
+ async function resolveSlot(
26
+ options: Omit<ResolveLayoutBlockDataOptions, "position">,
27
+ position: Position,
28
+ ) {
29
+ const resolved = await resolveEditorLayoutBlockData({ ...options, position });
30
+ return { data: resolved.data, resolvedContent: resolved.content };
31
+ }
32
+
17
33
  export async function loader(args: Route.LoaderArgs) {
18
34
  const data = await cmssyLoader(args);
19
35
  const resolved: EditorBlockData = data.isEdit
@@ -27,7 +43,27 @@ export async function loader(args: Route.LoaderArgs) {
27
43
  config: cmssy,
28
44
  });
29
45
 
30
- return { ...data, blockData: resolved.data, blockContent: resolved.content };
46
+ const slotOptions = {
47
+ groups: data.layouts,
48
+ blocks,
49
+ locale: data.locale,
50
+ defaultLocale: data.defaultLocale,
51
+ enabledLocales: data.enabledLocales,
52
+ config: cmssy,
53
+ };
54
+ const [header, footer] = data.isEdit
55
+ ? [data.editorData?.header, data.editorData?.footer]
56
+ : await Promise.all([
57
+ resolveSlot(slotOptions, "header"),
58
+ resolveSlot(slotOptions, "footer"),
59
+ ]);
60
+
61
+ return {
62
+ ...data,
63
+ blockData: resolved.data,
64
+ blockContent: resolved.content,
65
+ layoutData: { header, footer },
66
+ };
31
67
  }
32
68
 
33
69
  export const headers = createCmssyHeaders(cmssy);
@@ -41,8 +77,9 @@ export default function CmssyPage({ loaderData }: Route.ComponentProps) {
41
77
  enabledLocales,
42
78
  isEdit,
43
79
  editorOrigin,
80
+ layoutRegions,
44
81
  diagnostics,
45
- editorData,
82
+ layoutData,
46
83
  blockData,
47
84
  blockContent,
48
85
  } = loaderData;
@@ -51,7 +88,7 @@ export default function CmssyPage({ loaderData }: Route.ComponentProps) {
51
88
  return <div dangerouslySetInnerHTML={{ __html: diagnostics }} />;
52
89
  }
53
90
 
54
- const slot = (position: "header" | "footer") => (
91
+ const slot = (position: Position) => (
55
92
  <LayoutSlot
56
93
  groups={layouts}
57
94
  position={position}
@@ -59,8 +96,8 @@ export default function CmssyPage({ loaderData }: Route.ComponentProps) {
59
96
  defaultLocale={defaultLocale}
60
97
  enabledLocales={enabledLocales}
61
98
  edit={isEdit ? { editorOrigin } : undefined}
62
- data={editorData?.[position]?.data}
63
- resolvedContent={editorData?.[position]?.resolvedContent}
99
+ data={layoutData[position]?.data}
100
+ resolvedContent={layoutData[position]?.resolvedContent}
64
101
  />
65
102
  );
66
103
 
@@ -73,7 +110,7 @@ export default function CmssyPage({ loaderData }: Route.ComponentProps) {
73
110
  locale={locale}
74
111
  defaultLocale={defaultLocale}
75
112
  enabledLocales={enabledLocales}
76
- edit={{ editorOrigin }}
113
+ edit={{ editorOrigin, layoutRegions }}
77
114
  />
78
115
  {slot("footer")}
79
116
  </>
@@ -1,7 +1,15 @@
1
- import { defineCmssyConfig } from "@cmssy/remix";
1
+ import { defineCmssyConfig, defineCmssyLayout } from "@cmssy/remix";
2
+
3
+ export const layout = defineCmssyLayout({
4
+ regions: [
5
+ { id: "header", label: "Header" },
6
+ { id: "footer", label: "Footer" },
7
+ ],
8
+ });
2
9
 
3
10
  export const cmssy = defineCmssyConfig({
4
11
  org: process.env.CMSSY_ORG_SLUG,
5
12
  workspaceSlug: process.env.CMSSY_WORKSPACE_SLUG,
6
13
  draftSecret: process.env.CMSSY_DRAFT_SECRET,
14
+ layout,
7
15
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/cli",
3
- "version": "12.14.1",
3
+ "version": "13.0.0",
4
4
  "description": "The cmssy CLI: `cmssy init` wires cmssy into an existing Next.js, Astro or React Router app; `cmssy link` connects it to a workspace and verifies the editor wiring.",
5
5
  "keywords": [
6
6
  "cmssy",
@@ -27,7 +27,7 @@
27
27
  "assets"
28
28
  ],
29
29
  "dependencies": {
30
- "@cmssy/core": "12.14.1"
30
+ "@cmssy/core": "13.0.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "^20.0.0",