@bagelink/blox 1.15.543 → 1.15.549

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.
@@ -26,9 +26,19 @@ const node_child_process = require("node:child_process");
26
26
  const os = require("node:os");
27
27
  const path = require("node:path");
28
28
  const process = require("node:process");
29
- const llmArtifacts = require("./validate-output-Dku8tCir.cjs");
29
+ const llmArtifacts = require("./validate-output-BrUqMZIw.cjs");
30
30
  const AUTO_SHARD_CAP = Number(process.env.BLOX_SSG_SHARD_CAP) || 6;
31
31
  const PREFETCH_BUDGET = Number(process.env.BLOX_SSG_PREFETCH_BUDGET) || 24;
32
+ const SEQUENTIAL_SHARDS = process.env.BLOX_SSG_SEQUENTIAL === "1";
33
+ function matchesCmsPath(pathname, cmsPaths) {
34
+ if (cmsPaths.has(pathname)) return true;
35
+ for (const template of cmsPaths) {
36
+ if (!template.includes(":")) continue;
37
+ const pattern = template.replace(/:[a-z_]+/g, "[^/]+");
38
+ if (new RegExp(`^${pattern}$`).test(pathname)) return true;
39
+ }
40
+ return false;
41
+ }
32
42
  function resolveShardCount(shards) {
33
43
  if (shards === "auto") {
34
44
  const cores = os.cpus().length || 4;
@@ -101,8 +111,8 @@ async function runSharded(opts) {
101
111
  opts.buildRequest
102
112
  );
103
113
  for (const p of siteData.paths) if (!paths.includes(p)) paths.push(p);
104
- const cmsPathSet = new Set(siteData.paths);
105
- const routerPaths = appPaths.filter((path2) => !cmsPathSet.has(path2));
114
+ const cmsPathSet = /* @__PURE__ */ new Set([...siteData.paths, ...siteData.pageSlugs]);
115
+ const routerPaths = appPaths.filter((path2) => !matchesCmsPath(path2, cmsPathSet));
106
116
  if (!paths.includes("/")) {
107
117
  paths.unshift("/");
108
118
  routerPaths.unshift("/");
@@ -127,7 +137,18 @@ async function runSharded(opts) {
127
137
  appPaths: routerPaths
128
138
  }), "utf8");
129
139
  const start = Date.now();
130
- const codes = total === 1 ? [await runShard(0, 1, [], opts, llmPartsDir, routePartsDir, siteDataFile)] : await Promise.all(Array.from({ length: total }, (_, i) => runShard(i, total, [], opts, llmPartsDir, routePartsDir, siteDataFile)));
140
+ let codes;
141
+ if (total === 1) {
142
+ codes = [await runShard(0, 1, [], opts, llmPartsDir, routePartsDir, siteDataFile)];
143
+ } else if (SEQUENTIAL_SHARDS) {
144
+ codes = [];
145
+ for (let index = 0; index < total; index++) {
146
+ codes.push(await runShard(index, total, [], opts, llmPartsDir, routePartsDir, siteDataFile));
147
+ if (codes[index] !== 0) break;
148
+ }
149
+ } else {
150
+ codes = await Promise.all(Array.from({ length: total }, (_, i) => runShard(i, total, [], opts, llmPartsDir, routePartsDir, siteDataFile)));
151
+ }
131
152
  const failed = codes.map((code, index) => ({ code, index })).filter(({ code }) => code !== 0);
132
153
  if (failed.length) {
133
154
  console.error(
@@ -137,7 +158,7 @@ async function runSharded(opts) {
137
158
  }
138
159
  if (process.env.BLOX_SSG_LLM !== "0") {
139
160
  try {
140
- const { mergeLlmParts } = await Promise.resolve().then(() => require("./validate-output-Dku8tCir.cjs")).then((n) => n.llmArtifacts);
161
+ const { mergeLlmParts } = await Promise.resolve().then(() => require("./validate-output-BrUqMZIw.cjs")).then((n) => n.llmArtifacts);
141
162
  const mergeWebsite = website;
142
163
  const partFiles = Array.from({ length: total }, (_, i) => path.join(llmPartsDir, `part.${i}.json`));
143
164
  const { pages } = await mergeLlmParts({
@@ -2,9 +2,19 @@ import { spawn } from "node:child_process";
2
2
  import os from "node:os";
3
3
  import path from "node:path";
4
4
  import process from "node:process";
5
- import { f as fetchCmsSiteData, g as generateSitemapArtifacts } from "./validate-output-XdxaXjgE.js";
5
+ import { f as fetchCmsSiteData, g as generateSitemapArtifacts } from "./validate-output-CaMwqCa1.js";
6
6
  const AUTO_SHARD_CAP = Number(process.env.BLOX_SSG_SHARD_CAP) || 6;
7
7
  const PREFETCH_BUDGET = Number(process.env.BLOX_SSG_PREFETCH_BUDGET) || 24;
8
+ const SEQUENTIAL_SHARDS = process.env.BLOX_SSG_SEQUENTIAL === "1";
9
+ function matchesCmsPath(pathname, cmsPaths) {
10
+ if (cmsPaths.has(pathname)) return true;
11
+ for (const template of cmsPaths) {
12
+ if (!template.includes(":")) continue;
13
+ const pattern = template.replace(/:[a-z_]+/g, "[^/]+");
14
+ if (new RegExp(`^${pattern}$`).test(pathname)) return true;
15
+ }
16
+ return false;
17
+ }
8
18
  function resolveShardCount(shards) {
9
19
  if (shards === "auto") {
10
20
  const cores = os.cpus().length || 4;
@@ -77,8 +87,8 @@ async function runSharded(opts) {
77
87
  opts.buildRequest
78
88
  );
79
89
  for (const p of siteData.paths) if (!paths.includes(p)) paths.push(p);
80
- const cmsPathSet = new Set(siteData.paths);
81
- const routerPaths = appPaths.filter((path2) => !cmsPathSet.has(path2));
90
+ const cmsPathSet = /* @__PURE__ */ new Set([...siteData.paths, ...siteData.pageSlugs]);
91
+ const routerPaths = appPaths.filter((path2) => !matchesCmsPath(path2, cmsPathSet));
82
92
  if (!paths.includes("/")) {
83
93
  paths.unshift("/");
84
94
  routerPaths.unshift("/");
@@ -103,7 +113,18 @@ async function runSharded(opts) {
103
113
  appPaths: routerPaths
104
114
  }), "utf8");
105
115
  const start = Date.now();
106
- const codes = total === 1 ? [await runShard(0, 1, [], opts, llmPartsDir, routePartsDir, siteDataFile)] : await Promise.all(Array.from({ length: total }, (_, i) => runShard(i, total, [], opts, llmPartsDir, routePartsDir, siteDataFile)));
116
+ let codes;
117
+ if (total === 1) {
118
+ codes = [await runShard(0, 1, [], opts, llmPartsDir, routePartsDir, siteDataFile)];
119
+ } else if (SEQUENTIAL_SHARDS) {
120
+ codes = [];
121
+ for (let index = 0; index < total; index++) {
122
+ codes.push(await runShard(index, total, [], opts, llmPartsDir, routePartsDir, siteDataFile));
123
+ if (codes[index] !== 0) break;
124
+ }
125
+ } else {
126
+ codes = await Promise.all(Array.from({ length: total }, (_, i) => runShard(i, total, [], opts, llmPartsDir, routePartsDir, siteDataFile)));
127
+ }
107
128
  const failed = codes.map((code, index) => ({ code, index })).filter(({ code }) => code !== 0);
108
129
  if (failed.length) {
109
130
  console.error(
@@ -113,7 +134,7 @@ async function runSharded(opts) {
113
134
  }
114
135
  if (process.env.BLOX_SSG_LLM !== "0") {
115
136
  try {
116
- const { mergeLlmParts } = await import("./validate-output-XdxaXjgE.js").then((n) => n.A);
137
+ const { mergeLlmParts } = await import("./validate-output-CaMwqCa1.js").then((n) => n.A);
117
138
  const mergeWebsite = website;
118
139
  const partFiles = Array.from({ length: total }, (_, i) => path.join(llmPartsDir, `part.${i}.json`));
119
140
  const { pages } = await mergeLlmParts({
package/dist/ssg/cli.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  const process = require("node:process");
4
4
  const fs = require("node:fs/promises");
5
5
  const ssg_buildGrant = require("./build-grant.cjs");
6
- const llmArtifacts = require("../validate-output-Dku8tCir.cjs");
6
+ const llmArtifacts = require("../validate-output-BrUqMZIw.cjs");
7
7
  function installFetchTimeout() {
8
8
  const ms = Number(process.env.BLOX_SSG_FETCH_TIMEOUT_MS) || 2e4;
9
9
  const original = globalThis.fetch;
@@ -141,7 +141,7 @@ Environment:
141
141
  if (shardsOpt !== null || routesCmd) {
142
142
  const { apiBase: apiBase2, websiteName: configWebsiteName2 } = await resolveApiBase(mode);
143
143
  const websiteName2 = process.env.WEBSITE_NAME ?? configWebsiteName2 ?? "default";
144
- const { runSharded } = await Promise.resolve().then(() => require("../shard-runner-DOK26Y78.cjs"));
144
+ const { runSharded } = await Promise.resolve().then(() => require("../shard-runner-BwSs_Ws5.cjs"));
145
145
  const code = await runSharded({
146
146
  shards: shardsOpt ?? "auto",
147
147
  mode,
package/dist/ssg/cli.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  import process from "node:process";
3
3
  import fs from "node:fs/promises";
4
4
  import { resolveBloxBuildGrant } from "./build-grant.mjs";
5
- import { v as validateSsgOutput, u as uploadBloxManifest, p as polyfillBloxSsgGlobals, f as fetchCmsSiteData, a as prerender } from "../validate-output-XdxaXjgE.js";
5
+ import { v as validateSsgOutput, u as uploadBloxManifest, p as polyfillBloxSsgGlobals, f as fetchCmsSiteData, a as prerender } from "../validate-output-CaMwqCa1.js";
6
6
  function installFetchTimeout() {
7
7
  const ms = Number(process.env.BLOX_SSG_FETCH_TIMEOUT_MS) || 2e4;
8
8
  const original = globalThis.fetch;
@@ -140,7 +140,7 @@ Environment:
140
140
  if (shardsOpt !== null || routesCmd) {
141
141
  const { apiBase: apiBase2, websiteName: configWebsiteName2 } = await resolveApiBase(mode);
142
142
  const websiteName2 = process.env.WEBSITE_NAME ?? configWebsiteName2 ?? "default";
143
- const { runSharded } = await import("../shard-runner-Ic_t76Xj.js");
143
+ const { runSharded } = await import("../shard-runner-C8zwo_6O.js");
144
144
  const code = await runSharded({
145
145
  shards: shardsOpt ?? "auto",
146
146
  mode,
@@ -10,6 +10,8 @@ export interface CmsSiteData {
10
10
  websiteId: string;
11
11
  website: WebsiteRead;
12
12
  paths: string[];
13
+ /** Published CMS page slugs, including dynamic templates. */
14
+ pageSlugs: string[];
13
15
  redirects: RedirectEntry[];
14
16
  /** Datastore collections referenced by any page's data_bindings. */
15
17
  collections: CollectionRef[];
@@ -1 +1 @@
1
- {"version":3,"file":"cms-routes.d.ts","sourceRoot":"","sources":["../../src/ssg/cms-routes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AAoB9D,2EAA2E;AAC3E,MAAM,WAAW,aAAa;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,WAAW;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,WAAW,CAAA;IACpB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,SAAS,EAAE,aAAa,EAAE,CAAA;IAC1B,oEAAoE;IACpE,WAAW,EAAE,aAAa,EAAE,CAAA;CAC5B;AAYD;;;GAGG;AACH,wBAAgB,iBAAiB,CAChC,KAAK,EAAE,MAAM,EAAE,EACf,aAAa,EAAE,MAAM,EACrB,gBAAgB,EAAE,MAAM,EAAE,GACxB,MAAM,EAAE,CASV;AAMD;;;GAGG;AACH,wBAAsB,gBAAgB,CACrC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,cAAc,GAAE,uBAA4B,GAC1C,OAAO,CAAC,WAAW,CAAC,CA4GtB;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAC3C,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,cAAc,GAAE,uBAA4B,GAC1C,OAAO,CAAC,MAAM,EAAE,CAAC,CAGnB"}
1
+ {"version":3,"file":"cms-routes.d.ts","sourceRoot":"","sources":["../../src/ssg/cms-routes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AAoB9D,2EAA2E;AAC3E,MAAM,WAAW,aAAa;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,WAAW;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,WAAW,CAAA;IACpB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,6DAA6D;IAC7D,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,SAAS,EAAE,aAAa,EAAE,CAAA;IAC1B,oEAAoE;IACpE,WAAW,EAAE,aAAa,EAAE,CAAA;CAC5B;AAYD;;;GAGG;AACH,wBAAgB,iBAAiB,CAChC,KAAK,EAAE,MAAM,EAAE,EACf,aAAa,EAAE,MAAM,EACrB,gBAAgB,EAAE,MAAM,EAAE,GACxB,MAAM,EAAE,CASV;AAMD;;;GAGG;AACH,wBAAsB,gBAAgB,CACrC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,cAAc,GAAE,uBAA4B,GAC1C,OAAO,CAAC,WAAW,CAAC,CA+GtB;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAC3C,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,cAAc,GAAE,uBAA4B,GAC1C,OAAO,CAAC,MAAM,EAAE,CAAC,CAGnB"}
@@ -22,7 +22,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
22
  mod
23
23
  ));
24
24
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
25
- const llmArtifacts = require("../validate-output-Dku8tCir.cjs");
25
+ const llmArtifacts = require("../validate-output-BrUqMZIw.cjs");
26
26
  const ssg_buildGrant = require("./build-grant.cjs");
27
27
  const ssg_client = require("./client.cjs");
28
28
  const pinia = require("pinia");
@@ -1,5 +1,5 @@
1
- import { b as buildPageHead, c as primaryContextEntry, d as buildJsonLd, e as extractPageText, B as BloxBuildResponseError, h as bloxBuildJson } from "../validate-output-XdxaXjgE.js";
2
- import { i, j, k, f, l, m, n, o, g, q, r, s, t, w, x, p, a, y, z, u, v } from "../validate-output-XdxaXjgE.js";
1
+ import { b as buildPageHead, c as primaryContextEntry, d as buildJsonLd, e as extractPageText, B as BloxBuildResponseError, h as bloxBuildJson } from "../validate-output-CaMwqCa1.js";
2
+ import { i, j, k, f, l, m, n, o, g, q, r, s, t, w, x, p, a, y, z, u, v } from "../validate-output-CaMwqCa1.js";
3
3
  import { parseBloxBuildGrantBody, resolveBloxBuildGrant } from "./build-grant.mjs";
4
4
  import { BLOX_STATE_WINDOW_KEY, BLOX_WEBSITE_ID_WINDOW_KEY } from "./client.mjs";
5
5
  import { BLOX_COLLECTIONS_WINDOW_KEY, BLOX_DATA_WINDOW_KEY, BLOX_PAGE_SEO_WINDOW_KEY, getCollectionCache, getEmbeddedWebsiteId, installBloxStateCache, installCollectionCache } from "./client.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"shard-runner.d.ts","sourceRoot":"","sources":["../../src/ssg/shard-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAQH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AAI9D,MAAM,WAAW,kBAAkB;IAClC,qDAAqD;IACrD,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAA;IACZ,uDAAuD;IACvD,OAAO,EAAE,MAAM,CAAA;IACf,sDAAsD;IACtD,WAAW,EAAE,MAAM,CAAA;IACnB,yEAAyE;IACzE,YAAY,CAAC,EAAE,uBAAuB,CAAA;IACtC,iFAAiF;IACjF,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,8FAA8F;IAC9F,eAAe,EAAE,MAAM,EAAE,CAAA;IACzB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CAClB;AA4ED;;GAEG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAoI1E"}
1
+ {"version":3,"file":"shard-runner.d.ts","sourceRoot":"","sources":["../../src/ssg/shard-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAQH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AAI9D,MAAM,WAAW,kBAAkB;IAClC,qDAAqD;IACrD,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAA;IACZ,uDAAuD;IACvD,OAAO,EAAE,MAAM,CAAA;IACf,sDAAsD;IACtD,WAAW,EAAE,MAAM,CAAA;IACnB,yEAAyE;IACzE,YAAY,CAAC,EAAE,uBAAuB,CAAA;IACtC,iFAAiF;IACjF,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,8FAA8F;IAC9F,eAAe,EAAE,MAAM,EAAE,CAAA;IACzB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CAClB;AAyFD;;GAEG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CA6I1E"}
@@ -131,6 +131,7 @@ async function fetchCmsSiteData(apiBase, websiteName, requestOptions = {}) {
131
131
  websiteId,
132
132
  website: website2,
133
133
  paths: localizedPaths,
134
+ pageSlugs: [...new Set(bundle.pages.flatMap((page) => page.slug ? [page.slug] : []))],
134
135
  redirects: bundle.redirects.filter((redirect) => redirect.from_path && redirect.to_path),
135
136
  collections: extractCollectionRefs(bundle.pages)
136
137
  };
@@ -154,9 +155,9 @@ async function fetchCmsSiteData(apiBase, websiteName, requestOptions = {}) {
154
155
  {},
155
156
  requestOptions
156
157
  );
157
- const pages = Array.isArray(pagesData) ? pagesData : pagesData.data ?? [];
158
- const localePaths = await expandRoutes(apiBase, pages, requestOptions, locale);
159
- return { locale, pages, paths: localePaths.map((path2) => localizePath(path2, locale, defaultLocale)) };
158
+ const pages2 = Array.isArray(pagesData) ? pagesData : pagesData.data ?? [];
159
+ const localePaths = await expandRoutes(apiBase, pages2, requestOptions, locale);
160
+ return { locale, pages: pages2, paths: localePaths.map((path2) => localizePath(path2, locale, defaultLocale)) };
160
161
  }));
161
162
  const paths = [...new Set(localizedPages.flatMap((result) => result.paths))];
162
163
  const pathSet = new Set(paths);
@@ -164,9 +165,9 @@ async function fetchCmsSiteData(apiBase, websiteName, requestOptions = {}) {
164
165
  const canonicalSlugById = new Map(
165
166
  defaultPages.flatMap((page) => page.id && page.slug && !page.slug.includes(":") ? [[page.id, page.slug]] : [])
166
167
  );
167
- const localeAliases = localizedPages.flatMap(({ locale, pages }) => {
168
+ const localeAliases = localizedPages.flatMap(({ locale, pages: pages2 }) => {
168
169
  if (locale === defaultLocale) return [];
169
- return pages.flatMap((page) => {
170
+ return pages2.flatMap((page) => {
170
171
  const canonicalSlug = page.id ? canonicalSlugById.get(page.id) : void 0;
171
172
  const fromPath = canonicalSlug ? localizePath(canonicalSlug, locale, defaultLocale) : "";
172
173
  if (page.status && page.status !== "published" || !canonicalSlug || !page.slug || page.slug.includes(":") || page.slug === canonicalSlug || pathSet.has(fromPath)) return [];
@@ -186,8 +187,10 @@ async function fetchCmsSiteData(apiBase, websiteName, requestOptions = {}) {
186
187
  const redirects = redirectItems.filter((r) => r.from_path && r.to_path);
187
188
  const explicitSources = new Set(redirects.map((redirect) => redirect.from_path.trim()));
188
189
  redirects.push(...localeAliases.filter((alias) => !explicitSources.has(alias.from_path)));
189
- const collections = extractCollectionRefs(localizedPages.flatMap((result) => result.pages));
190
- return { websiteId: site.id, website, paths, redirects, collections };
190
+ const pages = localizedPages.flatMap((result) => result.pages);
191
+ const collections = extractCollectionRefs(pages);
192
+ const pageSlugs = [...new Set(pages.flatMap((page) => page.slug ? [page.slug] : []))];
193
+ return { websiteId: site.id, website, paths, pageSlugs, redirects, collections };
191
194
  }
192
195
  async function fetchCmsPrerenderPaths(apiBase, websiteName, requestOptions = {}) {
193
196
  const { paths } = await fetchCmsSiteData(apiBase, websiteName, requestOptions);
@@ -108,6 +108,7 @@ async function fetchCmsSiteData(apiBase, websiteName, requestOptions = {}) {
108
108
  websiteId,
109
109
  website: website2,
110
110
  paths: localizedPaths,
111
+ pageSlugs: [...new Set(bundle.pages.flatMap((page) => page.slug ? [page.slug] : []))],
111
112
  redirects: bundle.redirects.filter((redirect) => redirect.from_path && redirect.to_path),
112
113
  collections: extractCollectionRefs(bundle.pages)
113
114
  };
@@ -131,9 +132,9 @@ async function fetchCmsSiteData(apiBase, websiteName, requestOptions = {}) {
131
132
  {},
132
133
  requestOptions
133
134
  );
134
- const pages = Array.isArray(pagesData) ? pagesData : pagesData.data ?? [];
135
- const localePaths = await expandRoutes(apiBase, pages, requestOptions, locale);
136
- return { locale, pages, paths: localePaths.map((path2) => localizePath(path2, locale, defaultLocale)) };
135
+ const pages2 = Array.isArray(pagesData) ? pagesData : pagesData.data ?? [];
136
+ const localePaths = await expandRoutes(apiBase, pages2, requestOptions, locale);
137
+ return { locale, pages: pages2, paths: localePaths.map((path2) => localizePath(path2, locale, defaultLocale)) };
137
138
  }));
138
139
  const paths = [...new Set(localizedPages.flatMap((result) => result.paths))];
139
140
  const pathSet = new Set(paths);
@@ -141,9 +142,9 @@ async function fetchCmsSiteData(apiBase, websiteName, requestOptions = {}) {
141
142
  const canonicalSlugById = new Map(
142
143
  defaultPages.flatMap((page) => page.id && page.slug && !page.slug.includes(":") ? [[page.id, page.slug]] : [])
143
144
  );
144
- const localeAliases = localizedPages.flatMap(({ locale, pages }) => {
145
+ const localeAliases = localizedPages.flatMap(({ locale, pages: pages2 }) => {
145
146
  if (locale === defaultLocale) return [];
146
- return pages.flatMap((page) => {
147
+ return pages2.flatMap((page) => {
147
148
  const canonicalSlug = page.id ? canonicalSlugById.get(page.id) : void 0;
148
149
  const fromPath = canonicalSlug ? localizePath(canonicalSlug, locale, defaultLocale) : "";
149
150
  if (page.status && page.status !== "published" || !canonicalSlug || !page.slug || page.slug.includes(":") || page.slug === canonicalSlug || pathSet.has(fromPath)) return [];
@@ -163,8 +164,10 @@ async function fetchCmsSiteData(apiBase, websiteName, requestOptions = {}) {
163
164
  const redirects = redirectItems.filter((r) => r.from_path && r.to_path);
164
165
  const explicitSources = new Set(redirects.map((redirect) => redirect.from_path.trim()));
165
166
  redirects.push(...localeAliases.filter((alias) => !explicitSources.has(alias.from_path)));
166
- const collections = extractCollectionRefs(localizedPages.flatMap((result) => result.pages));
167
- return { websiteId: site.id, website, paths, redirects, collections };
167
+ const pages = localizedPages.flatMap((result) => result.pages);
168
+ const collections = extractCollectionRefs(pages);
169
+ const pageSlugs = [...new Set(pages.flatMap((page) => page.slug ? [page.slug] : []))];
170
+ return { websiteId: site.id, website, paths, pageSlugs, redirects, collections };
168
171
  }
169
172
  async function fetchCmsPrerenderPaths(apiBase, websiteName, requestOptions = {}) {
170
173
  const { paths } = await fetchCmsSiteData(apiBase, websiteName, requestOptions);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/blox",
3
3
  "type": "module",
4
- "version": "1.15.543",
4
+ "version": "1.15.549",
5
5
  "description": "Blox page builder library for drag-and-drop page building and static data management",
6
6
  "author": {
7
7
  "name": "Bagel Studio",