@sprintup-cms/sdk 1.8.49 → 1.8.51
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 +25 -0
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +8 -0
- package/dist/client.d.ts +8 -0
- package/dist/client.js +25 -0
- package/dist/client.js.map +1 -1
- package/dist/index.cjs +25 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -1
- package/dist/next/index.cjs +124 -6
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.js +124 -6
- package/dist/next/index.js.map +1 -1
- package/package.json +1 -1
package/dist/next/index.js
CHANGED
|
@@ -257,9 +257,34 @@ function createCMSClient(options) {
|
|
|
257
257
|
return null;
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
|
+
async function getGlobals() {
|
|
261
|
+
const { baseUrl, appId } = cfg();
|
|
262
|
+
if (!baseUrl || !appId) return { navigation: null, footer: null };
|
|
263
|
+
try {
|
|
264
|
+
const res = await fetch(`${baseUrl}/api/v1/${appId}/globals`, {
|
|
265
|
+
headers: headers(),
|
|
266
|
+
next: { revalidate: 300, tags: [`cms-globals-${appId}`] }
|
|
267
|
+
});
|
|
268
|
+
if (!res.ok) {
|
|
269
|
+
const [navPages, footerPages] = await Promise.all([
|
|
270
|
+
getPages({ type: "navigation" }),
|
|
271
|
+
getPages({ type: "footer" })
|
|
272
|
+
]);
|
|
273
|
+
return { navigation: navPages[0] ?? null, footer: footerPages[0] ?? null };
|
|
274
|
+
}
|
|
275
|
+
const json = await res.json();
|
|
276
|
+
return {
|
|
277
|
+
navigation: json.data?.navigation ?? null,
|
|
278
|
+
footer: json.data?.footer ?? null
|
|
279
|
+
};
|
|
280
|
+
} catch {
|
|
281
|
+
return { navigation: null, footer: null };
|
|
282
|
+
}
|
|
283
|
+
}
|
|
260
284
|
return {
|
|
261
285
|
getPages,
|
|
262
286
|
getPage,
|
|
287
|
+
getGlobals,
|
|
263
288
|
getBlogPosts,
|
|
264
289
|
getEvents,
|
|
265
290
|
getAnnouncements,
|
|
@@ -1120,6 +1145,97 @@ function ServerProductListBlock({ block }) {
|
|
|
1120
1145
|
}) })
|
|
1121
1146
|
] }) });
|
|
1122
1147
|
}
|
|
1148
|
+
function parseNavItems(html) {
|
|
1149
|
+
if (!html) return [];
|
|
1150
|
+
const text = html.replace(/<[^>]*>/g, "").replace(/ /g, " ");
|
|
1151
|
+
return text.split(/\r?\n/).filter(Boolean).map((line) => {
|
|
1152
|
+
const [label, url] = line.split("|").map((s) => s.trim());
|
|
1153
|
+
return { label: label || "", url: url || "#" };
|
|
1154
|
+
});
|
|
1155
|
+
}
|
|
1156
|
+
function CMSHeader({ nav }) {
|
|
1157
|
+
if (!nav) return null;
|
|
1158
|
+
const primary = nav.sections?.primary ?? nav.content?.primary ?? nav.primary ?? {};
|
|
1159
|
+
const navItems = parseNavItems(primary.nav_items || "");
|
|
1160
|
+
const logoUrl = primary.logo_url || "";
|
|
1161
|
+
const logoAlt = primary.logo_alt || "";
|
|
1162
|
+
if (!logoUrl && !logoAlt && navItems.length === 0) return null;
|
|
1163
|
+
return /* @__PURE__ */ jsx("header", { className: "w-full border-b border-border bg-background/95 backdrop-blur sticky top-0 z-50", children: /* @__PURE__ */ jsxs("div", { className: "max-w-6xl mx-auto px-4 h-16 flex items-center justify-between gap-4", children: [
|
|
1164
|
+
/* @__PURE__ */ jsxs("a", { href: "/", className: "flex items-center gap-2 shrink-0", children: [
|
|
1165
|
+
logoUrl && /* @__PURE__ */ jsx("img", { src: logoUrl, alt: logoAlt || "Logo", className: "h-8 w-auto" }),
|
|
1166
|
+
!logoUrl && logoAlt && /* @__PURE__ */ jsx("span", { className: "font-bold text-base", children: logoAlt })
|
|
1167
|
+
] }),
|
|
1168
|
+
navItems.length > 0 && /* @__PURE__ */ jsx("nav", { className: "hidden md:flex items-center gap-6", children: navItems.map((item, i) => /* @__PURE__ */ jsx("a", { href: item.url, className: "text-sm text-muted-foreground hover:text-foreground transition-colors", children: item.label }, i)) })
|
|
1169
|
+
] }) });
|
|
1170
|
+
}
|
|
1171
|
+
function parseFooterColumns(html) {
|
|
1172
|
+
if (!html) return [];
|
|
1173
|
+
const text = html.replace(/<[^>]*>/g, "").replace(/ /g, " ");
|
|
1174
|
+
const lines = text.split(/\r?\n/).filter(Boolean);
|
|
1175
|
+
const cols = [];
|
|
1176
|
+
let current = null;
|
|
1177
|
+
for (const line of lines) {
|
|
1178
|
+
const parts = line.split("|").map((s) => s.trim());
|
|
1179
|
+
if (parts.length === 1) {
|
|
1180
|
+
if (current) cols.push(current);
|
|
1181
|
+
current = { title: parts[0], links: [] };
|
|
1182
|
+
} else if (parts.length >= 2) {
|
|
1183
|
+
if (!current) current = { title: "", links: [] };
|
|
1184
|
+
current.links.push({ label: parts[0], url: parts[1] || "#" });
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
if (current) cols.push(current);
|
|
1188
|
+
return cols;
|
|
1189
|
+
}
|
|
1190
|
+
function parseLegalLinks(html) {
|
|
1191
|
+
if (!html) return [];
|
|
1192
|
+
const text = html.replace(/<[^>]*>/g, "").replace(/ /g, " ");
|
|
1193
|
+
return text.split(/\r?\n/).filter(Boolean).map((line) => {
|
|
1194
|
+
const [label, url] = line.split("|").map((s) => s.trim());
|
|
1195
|
+
return { label: label || "", url: url || "#" };
|
|
1196
|
+
});
|
|
1197
|
+
}
|
|
1198
|
+
function CMSFooter({ footer }) {
|
|
1199
|
+
if (!footer) return null;
|
|
1200
|
+
const c = footer.sections?.content ?? footer.content?.content ?? footer.content ?? {};
|
|
1201
|
+
const contact = footer.sections?.contact ?? footer.content?.contact ?? footer.contact ?? {};
|
|
1202
|
+
const social = footer.sections?.social ?? footer.content?.social ?? footer.social ?? {};
|
|
1203
|
+
const legal = footer.sections?.legal ?? footer.content?.legal ?? footer.legal ?? {};
|
|
1204
|
+
const columns = parseFooterColumns(c.columns || "");
|
|
1205
|
+
const legalLinks = parseLegalLinks(legal.legal_links || "");
|
|
1206
|
+
const hasSocial = social.facebook || social.twitter || social.instagram || social.linkedin || social.youtube;
|
|
1207
|
+
const isEmpty = !c.tagline && !c.logo_url && columns.length === 0 && !contact.email && !contact.phone && !hasSocial && !legal.copyright && legalLinks.length === 0;
|
|
1208
|
+
if (isEmpty) return null;
|
|
1209
|
+
return /* @__PURE__ */ jsx("footer", { className: "border-t border-border bg-muted/30 pt-12 pb-6 mt-16", children: /* @__PURE__ */ jsxs("div", { className: "max-w-6xl mx-auto px-4", children: [
|
|
1210
|
+
(c.tagline || c.logo_url || columns.length > 0 || contact.email) && /* @__PURE__ */ jsxs("div", { className: `grid gap-8 mb-10 grid-cols-1 sm:grid-cols-2 ${columns.length > 0 ? "lg:grid-cols-4" : "lg:grid-cols-2"}`, children: [
|
|
1211
|
+
(c.logo_url || c.tagline) && /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
1212
|
+
c.logo_url && /* @__PURE__ */ jsx("img", { src: c.logo_url, alt: "Logo", className: "h-8 w-auto" }),
|
|
1213
|
+
c.tagline && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground leading-relaxed", children: c.tagline })
|
|
1214
|
+
] }),
|
|
1215
|
+
columns.map((col, i) => /* @__PURE__ */ jsxs("div", { children: [
|
|
1216
|
+
col.title && /* @__PURE__ */ jsx("h4", { className: "font-semibold text-sm mb-3", children: col.title }),
|
|
1217
|
+
/* @__PURE__ */ jsx("ul", { className: "space-y-2", children: col.links.map((link, j) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("a", { href: link.url, className: "text-sm text-muted-foreground hover:text-foreground transition-colors", children: link.label }) }, j)) })
|
|
1218
|
+
] }, i)),
|
|
1219
|
+
(contact.email || contact.phone || contact.address) && /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
1220
|
+
/* @__PURE__ */ jsx("h4", { className: "font-semibold text-sm mb-3", children: "Contact" }),
|
|
1221
|
+
contact.email && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: contact.email }),
|
|
1222
|
+
contact.phone && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: contact.phone }),
|
|
1223
|
+
contact.address && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground whitespace-pre-line", children: contact.address })
|
|
1224
|
+
] })
|
|
1225
|
+
] }),
|
|
1226
|
+
hasSocial && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-4 mb-6", children: [
|
|
1227
|
+
social.facebook && /* @__PURE__ */ jsx("a", { href: social.facebook, className: "text-sm text-muted-foreground hover:text-foreground transition-colors", children: "Facebook" }),
|
|
1228
|
+
social.twitter && /* @__PURE__ */ jsx("a", { href: social.twitter, className: "text-sm text-muted-foreground hover:text-foreground transition-colors", children: "X" }),
|
|
1229
|
+
social.instagram && /* @__PURE__ */ jsx("a", { href: social.instagram, className: "text-sm text-muted-foreground hover:text-foreground transition-colors", children: "Instagram" }),
|
|
1230
|
+
social.linkedin && /* @__PURE__ */ jsx("a", { href: social.linkedin, className: "text-sm text-muted-foreground hover:text-foreground transition-colors", children: "LinkedIn" }),
|
|
1231
|
+
social.youtube && /* @__PURE__ */ jsx("a", { href: social.youtube, className: "text-sm text-muted-foreground hover:text-foreground transition-colors", children: "YouTube" })
|
|
1232
|
+
] }),
|
|
1233
|
+
(legal.copyright || legalLinks.length > 0) && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center justify-between gap-4 pt-6 border-t border-border", children: [
|
|
1234
|
+
legal.copyright && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: legal.copyright }),
|
|
1235
|
+
legalLinks.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-4", children: legalLinks.map((link, i) => /* @__PURE__ */ jsx("a", { href: link.url, className: "text-xs text-muted-foreground hover:text-foreground transition-colors", children: link.label }, i)) })
|
|
1236
|
+
] })
|
|
1237
|
+
] }) });
|
|
1238
|
+
}
|
|
1123
1239
|
var client = createCMSClient();
|
|
1124
1240
|
async function generateMetadata({ params }) {
|
|
1125
1241
|
const { slug } = await params;
|
|
@@ -1176,12 +1292,13 @@ async function CMSCatchAllPage({ params }) {
|
|
|
1176
1292
|
page = await client.getPage(slugStr);
|
|
1177
1293
|
}
|
|
1178
1294
|
if (!page) notFound();
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1295
|
+
const [pageType, globals] = await Promise.all([
|
|
1296
|
+
page.pageTypeId ? client.getPageType(page.pageTypeId) : Promise.resolve(null),
|
|
1297
|
+
client.getGlobals().catch(() => ({ navigation: null, footer: null }))
|
|
1298
|
+
]);
|
|
1183
1299
|
const resolvedBlocks = await resolveProductListBlocks(page.blocks ?? []);
|
|
1184
|
-
return /* @__PURE__ */ jsxs("div", { className: "min-h-screen bg-background", children: [
|
|
1300
|
+
return /* @__PURE__ */ jsxs("div", { className: "min-h-screen bg-background flex flex-col", children: [
|
|
1301
|
+
/* @__PURE__ */ jsx(CMSHeader, { nav: globals?.navigation }),
|
|
1185
1302
|
isPreview && /* @__PURE__ */ jsxs("div", { className: "sticky top-0 z-50 flex items-center justify-between px-4 py-2.5 bg-amber-500 text-white text-sm font-medium shadow", children: [
|
|
1186
1303
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1187
1304
|
/* @__PURE__ */ jsx("span", { children: "Draft Preview" }),
|
|
@@ -1210,7 +1327,8 @@ async function CMSCatchAllPage({ params }) {
|
|
|
1210
1327
|
] }) : /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center py-24 text-muted-foreground border-2 border-dashed border-border rounded-xl", children: [
|
|
1211
1328
|
/* @__PURE__ */ jsx("p", { className: "text-sm", children: "No content added yet." }),
|
|
1212
1329
|
isPreview && /* @__PURE__ */ jsx("p", { className: "text-xs mt-1 opacity-60", children: "Add blocks in the CMS editor to see them here." })
|
|
1213
|
-
] }) })
|
|
1330
|
+
] }) }),
|
|
1331
|
+
/* @__PURE__ */ jsx(CMSFooter, { footer: globals?.footer })
|
|
1214
1332
|
] });
|
|
1215
1333
|
}
|
|
1216
1334
|
async function dynamicProxyGET(req) {
|