@cmssy/cli 12.14.1 → 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
  </>
@@ -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>
@@ -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
  </>
@@ -3,7 +3,9 @@ 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
10
  import { createCmssyHeaders, createCmssyLoader } from "@cmssy/remix";
9
11
  import { cmssy } from "../../cmssy.config";
@@ -14,6 +16,16 @@ import type { Route } from "./+types/page";
14
16
 
15
17
  const cmssyLoader = createCmssyLoader(cmssy, { blocks });
16
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
+
17
29
  export async function loader(args: Route.LoaderArgs) {
18
30
  const data = await cmssyLoader(args);
19
31
  const resolved: EditorBlockData = data.isEdit
@@ -27,7 +39,27 @@ export async function loader(args: Route.LoaderArgs) {
27
39
  config: cmssy,
28
40
  });
29
41
 
30
- return { ...data, blockData: resolved.data, blockContent: resolved.content };
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
+ };
31
63
  }
32
64
 
33
65
  export const headers = createCmssyHeaders(cmssy);
@@ -42,7 +74,7 @@ export default function CmssyPage({ loaderData }: Route.ComponentProps) {
42
74
  isEdit,
43
75
  editorOrigin,
44
76
  diagnostics,
45
- editorData,
77
+ layoutData,
46
78
  blockData,
47
79
  blockContent,
48
80
  } = loaderData;
@@ -51,7 +83,7 @@ export default function CmssyPage({ loaderData }: Route.ComponentProps) {
51
83
  return <div dangerouslySetInnerHTML={{ __html: diagnostics }} />;
52
84
  }
53
85
 
54
- const slot = (position: "header" | "footer") => (
86
+ const slot = (position: Position) => (
55
87
  <LayoutSlot
56
88
  groups={layouts}
57
89
  position={position}
@@ -59,8 +91,8 @@ export default function CmssyPage({ loaderData }: Route.ComponentProps) {
59
91
  defaultLocale={defaultLocale}
60
92
  enabledLocales={enabledLocales}
61
93
  edit={isEdit ? { editorOrigin } : undefined}
62
- data={editorData?.[position]?.data}
63
- resolvedContent={editorData?.[position]?.resolvedContent}
94
+ data={layoutData[position]?.data}
95
+ resolvedContent={layoutData[position]?.resolvedContent}
64
96
  />
65
97
  );
66
98
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/cli",
3
- "version": "12.14.1",
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.1"
30
+ "@cmssy/core": "12.14.2"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "^20.0.0",