@sleekcms/client 3.1.1 → 3.3.0
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/README.md +12 -1
- package/index.cjs +9 -10
- package/index.d.cts +6 -3
- package/index.d.ts +6 -3
- package/index.global.js +9 -10
- package/index.global.js.map +1 -1
- package/index.global.min.js +1 -1
- package/index.global.min.js.map +1 -1
- package/index.mjs +9 -10
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -105,8 +105,6 @@ async function fetchSiteContent(options) {
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
return cachedData.data;
|
|
108
|
-
} else {
|
|
109
|
-
return cachedData;
|
|
110
108
|
}
|
|
111
109
|
} catch (e) {
|
|
112
110
|
}
|
|
@@ -128,11 +126,13 @@ function extractSlugs(pages, path) {
|
|
|
128
126
|
}
|
|
129
127
|
return slugs;
|
|
130
128
|
}
|
|
131
|
-
function filterPagesByPath(pages, path) {
|
|
129
|
+
function filterPagesByPath(pages, path, options) {
|
|
132
130
|
const pagesList = pages ?? [];
|
|
133
131
|
return pagesList.filter((p) => {
|
|
134
132
|
const pth = typeof p._path === "string" ? p._path : "";
|
|
135
|
-
|
|
133
|
+
if (path && !pth.startsWith(path)) return false;
|
|
134
|
+
if ((options == null ? void 0 : options.collection) && !("_slug" in p)) return false;
|
|
135
|
+
return true;
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
138
|
|
|
@@ -152,11 +152,11 @@ async function createSyncClient(options) {
|
|
|
152
152
|
function getContent(query) {
|
|
153
153
|
return applyJmes(data, query);
|
|
154
154
|
}
|
|
155
|
-
function getPages(path) {
|
|
155
|
+
function getPages(path, options2) {
|
|
156
156
|
if (!path) {
|
|
157
157
|
throw new Error("[SleekCMS] path is required for getPages");
|
|
158
158
|
}
|
|
159
|
-
return filterPagesByPath(data.pages, path);
|
|
159
|
+
return filterPagesByPath(data.pages, path, options2);
|
|
160
160
|
}
|
|
161
161
|
function getPage(path) {
|
|
162
162
|
if (!path) {
|
|
@@ -215,11 +215,10 @@ function createAsyncClient(options) {
|
|
|
215
215
|
if (!search2) return null;
|
|
216
216
|
return await fetchSiteContent({ siteToken, env, search: search2, lang, cache, resolveEnv });
|
|
217
217
|
}
|
|
218
|
-
async function getPages(path) {
|
|
219
|
-
if (syncClient) return syncClient.getPages(path);
|
|
218
|
+
async function getPages(path, options2) {
|
|
219
|
+
if (syncClient) return syncClient.getPages(path, options2);
|
|
220
220
|
const pages = await fetchSiteContent({ siteToken, env, search: "pages", lang, cache, resolveEnv });
|
|
221
|
-
|
|
222
|
-
else return filterPagesByPath(pages, path);
|
|
221
|
+
return filterPagesByPath(pages, path, options2);
|
|
223
222
|
}
|
|
224
223
|
async function getPage(path) {
|
|
225
224
|
if (syncClient) return syncClient.getPage(path);
|