@cmssy/cli 12.14.0 → 12.14.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.
@@ -63,6 +63,8 @@ export default function LayoutSlot({
63
63
  locale={locale}
64
64
  defaultLocale={defaultLocale}
65
65
  context={context}
66
+ resolvedContent={resolvedContent?.[block.id]}
67
+ data={data?.[block.id]}
66
68
  />
67
69
  ))}
68
70
  </>
@@ -7,11 +7,15 @@ export function Blocks({
7
7
  locale,
8
8
  defaultLocale,
9
9
  enabledLocales,
10
+ blockData,
11
+ blockContent,
10
12
  }: {
11
13
  page: CmssyPageData;
12
14
  locale: string;
13
15
  defaultLocale: string;
14
16
  enabledLocales: string[];
17
+ blockData: Record<string, unknown>;
18
+ blockContent: Record<string, Record<string, unknown>>;
15
19
  }) {
16
20
  const blockMap = buildBlockMap(blocks);
17
21
  const context = buildBlockContext(locale, defaultLocale, enabledLocales);
@@ -26,6 +30,8 @@ export function Blocks({
26
30
  locale={locale}
27
31
  defaultLocale={defaultLocale}
28
32
  context={context}
33
+ resolvedContent={blockContent[block.id]}
34
+ data={blockData[block.id]}
29
35
  />
30
36
  ))}
31
37
  </>
@@ -1,5 +1,9 @@
1
1
  ---
2
2
  import { loadCmssyPage } from "@cmssy/astro";
3
+ import {
4
+ resolveEditorBlockData,
5
+ resolveEditorLayoutBlockData,
6
+ } from "@cmssy/react";
3
7
  import { cmssy } from "../cmssy.config";
4
8
  import { blocks } from "../cmssy/blocks";
5
9
  import { Blocks } from "../components/Blocks";
@@ -17,6 +21,28 @@ const { page, layouts, locale, defaultLocale, enabledLocales } = await loadCmssy
17
21
  if (!page) {
18
22
  Astro.response.status = 404;
19
23
  }
24
+
25
+ const { data: blockData, content: blockContent } = await resolveEditorBlockData({
26
+ page,
27
+ blocks,
28
+ locale,
29
+ defaultLocale,
30
+ enabledLocales,
31
+ config: cmssy,
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
+ ]);
20
46
  ---
21
47
 
22
48
  <html lang={locale}>
@@ -31,6 +57,8 @@ if (!page) {
31
57
  locale={locale}
32
58
  defaultLocale={defaultLocale}
33
59
  enabledLocales={enabledLocales}
60
+ data={header.data}
61
+ resolvedContent={header.content}
34
62
  />
35
63
  {
36
64
  page ? (
@@ -39,6 +67,8 @@ if (!page) {
39
67
  locale={locale}
40
68
  defaultLocale={defaultLocale}
41
69
  enabledLocales={enabledLocales}
70
+ blockData={blockData}
71
+ blockContent={blockContent}
42
72
  />
43
73
  ) : (
44
74
  <main><h1>Not found</h1></main>
@@ -50,6 +80,8 @@ if (!page) {
50
80
  locale={locale}
51
81
  defaultLocale={defaultLocale}
52
82
  enabledLocales={enabledLocales}
83
+ data={footer.data}
84
+ resolvedContent={footer.content}
53
85
  />
54
86
  </body>
55
87
  </html>
@@ -63,6 +63,8 @@ export function LayoutSlot({
63
63
  locale={locale}
64
64
  defaultLocale={defaultLocale}
65
65
  context={context}
66
+ resolvedContent={resolvedContent?.[block.id]}
67
+ data={data?.[block.id]}
66
68
  />
67
69
  ))}
68
70
  </>
@@ -1,4 +1,12 @@
1
- import { CmssyBlock, buildBlockContext, buildBlockMap } from "@cmssy/react";
1
+ import {
2
+ CmssyBlock,
3
+ buildBlockContext,
4
+ buildBlockMap,
5
+ resolveEditorBlockData,
6
+ resolveEditorLayoutBlockData,
7
+ type EditorBlockData,
8
+ type ResolveLayoutBlockDataOptions,
9
+ } from "@cmssy/react";
2
10
  import { createCmssyHeaders, createCmssyLoader } from "@cmssy/remix";
3
11
  import { cmssy } from "../../cmssy.config";
4
12
  import { blocks } from "../cmssy/blocks";
@@ -6,7 +14,53 @@ import { CmssyEditor } from "../cmssy/editor";
6
14
  import { LayoutSlot } from "../cmssy/layout-slot";
7
15
  import type { Route } from "./+types/page";
8
16
 
9
- export const loader = createCmssyLoader(cmssy, { blocks });
17
+ const cmssyLoader = createCmssyLoader(cmssy, { blocks });
18
+
19
+ type Position = "header" | "footer";
20
+
21
+ async function resolveSlot(
22
+ options: Omit<ResolveLayoutBlockDataOptions, "position">,
23
+ position: Position,
24
+ ) {
25
+ const resolved = await resolveEditorLayoutBlockData({ ...options, position });
26
+ return { data: resolved.data, resolvedContent: resolved.content };
27
+ }
28
+
29
+ export async function loader(args: Route.LoaderArgs) {
30
+ const data = await cmssyLoader(args);
31
+ const resolved: EditorBlockData = data.isEdit
32
+ ? { data: {}, content: {} }
33
+ : await resolveEditorBlockData({
34
+ page: data.page,
35
+ blocks,
36
+ locale: data.locale,
37
+ defaultLocale: data.defaultLocale,
38
+ enabledLocales: data.enabledLocales,
39
+ config: cmssy,
40
+ });
41
+
42
+ const slotOptions = {
43
+ groups: data.layouts,
44
+ blocks,
45
+ locale: data.locale,
46
+ defaultLocale: data.defaultLocale,
47
+ enabledLocales: data.enabledLocales,
48
+ config: cmssy,
49
+ };
50
+ const [header, footer] = data.isEdit
51
+ ? [data.editorData?.header, data.editorData?.footer]
52
+ : await Promise.all([
53
+ resolveSlot(slotOptions, "header"),
54
+ resolveSlot(slotOptions, "footer"),
55
+ ]);
56
+
57
+ return {
58
+ ...data,
59
+ blockData: resolved.data,
60
+ blockContent: resolved.content,
61
+ layoutData: { header, footer },
62
+ };
63
+ }
10
64
 
11
65
  export const headers = createCmssyHeaders(cmssy);
12
66
 
@@ -20,14 +74,16 @@ export default function CmssyPage({ loaderData }: Route.ComponentProps) {
20
74
  isEdit,
21
75
  editorOrigin,
22
76
  diagnostics,
23
- editorData,
77
+ layoutData,
78
+ blockData,
79
+ blockContent,
24
80
  } = loaderData;
25
81
 
26
82
  if (diagnostics) {
27
83
  return <div dangerouslySetInnerHTML={{ __html: diagnostics }} />;
28
84
  }
29
85
 
30
- const slot = (position: "header" | "footer") => (
86
+ const slot = (position: Position) => (
31
87
  <LayoutSlot
32
88
  groups={layouts}
33
89
  position={position}
@@ -35,8 +91,8 @@ export default function CmssyPage({ loaderData }: Route.ComponentProps) {
35
91
  defaultLocale={defaultLocale}
36
92
  enabledLocales={enabledLocales}
37
93
  edit={isEdit ? { editorOrigin } : undefined}
38
- data={editorData?.[position]?.data}
39
- resolvedContent={editorData?.[position]?.resolvedContent}
94
+ data={layoutData[position]?.data}
95
+ resolvedContent={layoutData[position]?.resolvedContent}
40
96
  />
41
97
  );
42
98
 
@@ -82,6 +138,8 @@ export default function CmssyPage({ loaderData }: Route.ComponentProps) {
82
138
  locale={locale}
83
139
  defaultLocale={defaultLocale}
84
140
  context={context}
141
+ resolvedContent={blockContent[block.id]}
142
+ data={blockData[block.id]}
85
143
  />
86
144
  ))}
87
145
  </main>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/cli",
3
- "version": "12.14.0",
3
+ "version": "12.14.2",
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.0"
30
+ "@cmssy/core": "12.14.2"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "^20.0.0",