@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/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
- return pth.startsWith(path);
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
- if (!path) return pages;
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sleekcms/client",
3
- "version": "3.1.1",
3
+ "version": "3.3.0",
4
4
  "description": "Official SleekCMS content client for Node 18+ and browser",
5
5
  "type": "module",
6
6
  "main": "index.cjs",