@sprintup-cms/sdk 1.9.2 → 1.9.4
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 +28 -27
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +15 -1
- package/dist/client.d.ts +15 -1
- package/dist/client.js +28 -28
- package/dist/client.js.map +1 -1
- package/dist/index.cjs +28 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +28 -28
- package/dist/index.js.map +1 -1
- package/dist/next/index.cjs +27 -27
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.js +27 -27
- package/dist/next/index.js.map +1 -1
- package/package.json +1 -1
package/dist/next/index.js
CHANGED
|
@@ -96,6 +96,32 @@ async function previewEntryGET(request) {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
// src/client.ts
|
|
99
|
+
function resolveNavItems(items = []) {
|
|
100
|
+
return items.map((item) => {
|
|
101
|
+
let href = "#";
|
|
102
|
+
if (item.type === "anchor") {
|
|
103
|
+
const anchorId = item.anchorTarget || "";
|
|
104
|
+
const anchorPage = item.anchorPage || "";
|
|
105
|
+
if (anchorId) {
|
|
106
|
+
href = anchorPage ? `/${anchorPage}#${anchorId}` : `#${anchorId}`;
|
|
107
|
+
}
|
|
108
|
+
} else if (item.url) {
|
|
109
|
+
href = item.url;
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
id: item.id ?? "",
|
|
113
|
+
type: item.type ?? "link",
|
|
114
|
+
label: item.label ?? "",
|
|
115
|
+
url: item.url,
|
|
116
|
+
anchorTarget: item.anchorTarget,
|
|
117
|
+
anchorPage: item.anchorPage,
|
|
118
|
+
href,
|
|
119
|
+
locked: item.locked ?? false,
|
|
120
|
+
openInNewTab: item.openInNewTab ?? false,
|
|
121
|
+
children: resolveNavItems(item.children ?? [])
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
}
|
|
99
125
|
function createCMSClient(options) {
|
|
100
126
|
function cfg() {
|
|
101
127
|
return {
|
|
@@ -257,32 +283,6 @@ function createCMSClient(options) {
|
|
|
257
283
|
return null;
|
|
258
284
|
}
|
|
259
285
|
}
|
|
260
|
-
function resolveNavItems(items = []) {
|
|
261
|
-
return items.map((item) => {
|
|
262
|
-
let href = "#";
|
|
263
|
-
if (item.type === "anchor") {
|
|
264
|
-
const anchorId = item.anchorTarget || "";
|
|
265
|
-
const anchorPage = item.anchorPage || "";
|
|
266
|
-
if (anchorId) {
|
|
267
|
-
href = anchorPage ? `/${anchorPage}#${anchorId}` : `#${anchorId}`;
|
|
268
|
-
}
|
|
269
|
-
} else if (item.url) {
|
|
270
|
-
href = item.url;
|
|
271
|
-
}
|
|
272
|
-
return {
|
|
273
|
-
id: item.id ?? "",
|
|
274
|
-
type: item.type ?? "link",
|
|
275
|
-
label: item.label ?? "",
|
|
276
|
-
url: item.url,
|
|
277
|
-
anchorTarget: item.anchorTarget,
|
|
278
|
-
anchorPage: item.anchorPage,
|
|
279
|
-
href,
|
|
280
|
-
locked: item.locked ?? false,
|
|
281
|
-
openInNewTab: item.openInNewTab ?? false,
|
|
282
|
-
children: resolveNavItems(item.children ?? [])
|
|
283
|
-
};
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
286
|
async function getGlobals() {
|
|
287
287
|
const { baseUrl, appId } = cfg();
|
|
288
288
|
if (!baseUrl || !appId) return { navigation: null, footer: null, navItems: [] };
|
|
@@ -294,7 +294,7 @@ function createCMSClient(options) {
|
|
|
294
294
|
if (!res.ok) return { navigation: null, footer: null, navItems: [] };
|
|
295
295
|
const json = await res.json();
|
|
296
296
|
const navigation = json.data?.navigation ?? null;
|
|
297
|
-
const rawItems = navigation?.
|
|
297
|
+
const rawItems = navigation?.sectionData?.items ?? navigation?.blocks?.[0]?.content?.items ?? [];
|
|
298
298
|
return {
|
|
299
299
|
navigation,
|
|
300
300
|
footer: json.data?.footer ?? null,
|