@sprintup-cms/sdk 1.9.6 → 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 +27 -0
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.js +27 -0
- package/dist/next/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,
|