@sprintup-cms/sdk 1.9.5 → 1.9.7
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/dist/client.cjs +27 -0
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +4 -0
- package/dist/client.d.ts +4 -0
- package/dist/client.js +27 -0
- package/dist/client.js.map +1 -1
- package/dist/index.cjs +27 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -1
- package/dist/next/index.cjs +74 -1
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.js +74 -1
- package/dist/next/index.js.map +1 -1
- package/dist/react/index.cjs +47 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +47 -1
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
package/dist/next/index.js
CHANGED
|
@@ -184,6 +184,32 @@ function createCMSClient(options) {
|
|
|
184
184
|
return null;
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
|
+
async function getRootPage() {
|
|
188
|
+
const { baseUrl, apiKey, appId } = cfg();
|
|
189
|
+
if (!baseUrl || !apiKey || !appId) {
|
|
190
|
+
console.warn("[sprintup-cms] getRootPage: Missing config \u2014 returning null");
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
try {
|
|
194
|
+
const res = await fetch(
|
|
195
|
+
`${baseUrl}/api/v1/${appId}/pages?isRootPage=true&limit=1`,
|
|
196
|
+
{
|
|
197
|
+
headers: headers(),
|
|
198
|
+
next: { revalidate: 60, tags: [`cms-pages-${appId}`] }
|
|
199
|
+
}
|
|
200
|
+
);
|
|
201
|
+
if (!res.ok) {
|
|
202
|
+
console.error(`[sprintup-cms] getRootPage (${res.status})`);
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
const json = await res.json();
|
|
206
|
+
const pages = Array.isArray(json.data) ? json.data : [];
|
|
207
|
+
return pages.find((p) => p.isRootPage === true) ?? pages[0] ?? null;
|
|
208
|
+
} catch (err) {
|
|
209
|
+
console.error("[sprintup-cms] getRootPage error:", err);
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
187
213
|
async function getBlogPosts() {
|
|
188
214
|
return getPages({ type: "blog-post" });
|
|
189
215
|
}
|
|
@@ -312,6 +338,7 @@ function createCMSClient(options) {
|
|
|
312
338
|
return {
|
|
313
339
|
getPages,
|
|
314
340
|
getPage,
|
|
341
|
+
getRootPage,
|
|
315
342
|
getGlobals,
|
|
316
343
|
getBlogPosts,
|
|
317
344
|
getEvents,
|
|
@@ -1197,6 +1224,50 @@ function TwoColumnBlock({ block }) {
|
|
|
1197
1224
|
!hasImage && /* @__PURE__ */ jsx("div", { className: "flex-1 w-full rounded-xl bg-muted border border-border aspect-video flex items-center justify-center", children: /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "No image set" }) })
|
|
1198
1225
|
] }) });
|
|
1199
1226
|
}
|
|
1227
|
+
function BentoGridBlock({ block }) {
|
|
1228
|
+
const d = getData(block);
|
|
1229
|
+
const items = Array.isArray(d.items) ? d.items : [];
|
|
1230
|
+
const sizeClass = {
|
|
1231
|
+
small: "col-span-1 row-span-1",
|
|
1232
|
+
wide: "col-span-2 row-span-1",
|
|
1233
|
+
tall: "col-span-1 row-span-2",
|
|
1234
|
+
large: "col-span-2 row-span-2"
|
|
1235
|
+
};
|
|
1236
|
+
return /* @__PURE__ */ jsxs("section", { className: "py-12", children: [
|
|
1237
|
+
(d.title || d.subtitle) && /* @__PURE__ */ jsxs("div", { className: "mb-8", children: [
|
|
1238
|
+
d.title && /* @__PURE__ */ jsx("h2", { className: "text-3xl font-semibold tracking-tight", children: d.title }),
|
|
1239
|
+
d.subtitle && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground mt-1", children: d.subtitle })
|
|
1240
|
+
] }),
|
|
1241
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-4 auto-rows-[180px] gap-3", children: items.map((item, i) => /* @__PURE__ */ jsxs(
|
|
1242
|
+
"div",
|
|
1243
|
+
{
|
|
1244
|
+
className: `rounded-xl border border-border bg-card p-5 flex flex-col justify-between hover:bg-muted/40 transition-colors ${sizeClass[item.size] ?? sizeClass.small}`,
|
|
1245
|
+
children: [
|
|
1246
|
+
/* @__PURE__ */ jsx("div", { className: "w-8 h-8 rounded-lg bg-muted flex items-center justify-center mb-3", children: FEATURE_ICONS[item.icon] ?? /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "w-4 h-4", children: /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "10" }) }) }),
|
|
1247
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1248
|
+
/* @__PURE__ */ jsx("h3", { className: "font-semibold text-sm", children: item.title }),
|
|
1249
|
+
item.description && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs mt-0.5 leading-relaxed", children: item.description })
|
|
1250
|
+
] })
|
|
1251
|
+
]
|
|
1252
|
+
},
|
|
1253
|
+
i
|
|
1254
|
+
)) })
|
|
1255
|
+
] });
|
|
1256
|
+
}
|
|
1257
|
+
function GridLayoutBlock({ block }) {
|
|
1258
|
+
const d = getData(block);
|
|
1259
|
+
const cols = Number(d.columns) || 3;
|
|
1260
|
+
const gap = String(d.gap ?? "md");
|
|
1261
|
+
const children = Array.isArray(d.children) ? d.children : [];
|
|
1262
|
+
const gapMap = { none: "gap-0", sm: "gap-2", md: "gap-4", lg: "gap-6", xl: "gap-8" };
|
|
1263
|
+
const colsMap = { 1: "grid-cols-1", 2: "grid-cols-2", 3: "grid-cols-3", 4: "grid-cols-4", 5: "grid-cols-5", 6: "grid-cols-6" };
|
|
1264
|
+
return /* @__PURE__ */ jsx("div", { className: `grid ${colsMap[cols] ?? "grid-cols-3"} ${gapMap[gap] ?? "gap-4"}`, children: children.map((child) => /* @__PURE__ */ jsx("div", { className: "min-w-0", children: /* @__PURE__ */ jsx(GridLayoutChildBlock, { block: child }) }, child.id)) });
|
|
1265
|
+
}
|
|
1266
|
+
function GridLayoutChildBlock({ block }) {
|
|
1267
|
+
const renderer = BUILT_IN[block.type];
|
|
1268
|
+
if (renderer) return /* @__PURE__ */ jsx(Fragment, { children: renderer(block, null) });
|
|
1269
|
+
return /* @__PURE__ */ jsx(SectionBlock, { block, pageType: null });
|
|
1270
|
+
}
|
|
1200
1271
|
var BUILT_IN = {
|
|
1201
1272
|
// Structured page type — content is nested { sectionName: { fieldName: value } }
|
|
1202
1273
|
"__structured__": (b, pt) => /* @__PURE__ */ jsx(StructuredBlock, { block: b, pageType: pt }),
|
|
@@ -1236,7 +1307,9 @@ var BUILT_IN = {
|
|
|
1236
1307
|
columns: (b) => /* @__PURE__ */ jsx(ColumnsBlock, { block: b }),
|
|
1237
1308
|
container: (b) => /* @__PURE__ */ jsx(ContainerBlock, { block: b }),
|
|
1238
1309
|
carousel: (b) => /* @__PURE__ */ jsx(CarouselBlock, { block: b }),
|
|
1239
|
-
"product-list": (b) => /* @__PURE__ */ jsx(ProductListBlock, { block: b })
|
|
1310
|
+
"product-list": (b) => /* @__PURE__ */ jsx(ProductListBlock, { block: b }),
|
|
1311
|
+
"bento-grid": (b) => /* @__PURE__ */ jsx(BentoGridBlock, { block: b }),
|
|
1312
|
+
"grid-layout": (b) => /* @__PURE__ */ jsx(GridLayoutBlock, { block: b })
|
|
1240
1313
|
};
|
|
1241
1314
|
function CMSBlocks({ blocks, pageType, className = "", custom = {} }) {
|
|
1242
1315
|
if (!blocks?.length) return null;
|