@bagelink/blox 1.15.547 → 1.15.551

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.
@@ -2,10 +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
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
+ }
9
18
  function resolveShardCount(shards) {
10
19
  if (shards === "auto") {
11
20
  const cores = os.cpus().length || 4;
@@ -78,8 +87,8 @@ async function runSharded(opts) {
78
87
  opts.buildRequest
79
88
  );
80
89
  for (const p of siteData.paths) if (!paths.includes(p)) paths.push(p);
81
- const cmsPathSet = new Set(siteData.paths);
82
- 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));
83
92
  if (!paths.includes("/")) {
84
93
  paths.unshift("/");
85
94
  routerPaths.unshift("/");
@@ -104,15 +113,23 @@ async function runSharded(opts) {
104
113
  appPaths: routerPaths
105
114
  }), "utf8");
106
115
  const start = Date.now();
116
+ const indexPath = path.resolve("dist", "index.html");
117
+ const pristineTemplate = await fs.readFile(indexPath, "utf8");
107
118
  let codes;
108
119
  if (total === 1) {
109
120
  codes = [await runShard(0, 1, [], opts, llmPartsDir, routePartsDir, siteDataFile)];
110
121
  } else if (SEQUENTIAL_SHARDS) {
111
122
  codes = [];
123
+ let renderedRoot = null;
112
124
  for (let index = 0; index < total; index++) {
125
+ await fs.writeFile(indexPath, pristineTemplate, "utf8");
113
126
  codes.push(await runShard(index, total, [], opts, llmPartsDir, routePartsDir, siteDataFile));
127
+ if (index === 0 && codes[index] === 0) {
128
+ renderedRoot = await fs.readFile(indexPath, "utf8");
129
+ }
114
130
  if (codes[index] !== 0) break;
115
131
  }
132
+ if (renderedRoot != null) await fs.writeFile(indexPath, renderedRoot, "utf8");
116
133
  } else {
117
134
  codes = await Promise.all(Array.from({ length: total }, (_, i) => runShard(i, total, [], opts, llmPartsDir, routePartsDir, siteDataFile)));
118
135
  }
@@ -125,7 +142,7 @@ async function runSharded(opts) {
125
142
  }
126
143
  if (process.env.BLOX_SSG_LLM !== "0") {
127
144
  try {
128
- const { mergeLlmParts } = await import("./validate-output-XdxaXjgE.js").then((n) => n.A);
145
+ const { mergeLlmParts } = await import("./validate-output-CaMwqCa1.js").then((n) => n.A);
129
146
  const mergeWebsite = website;
130
147
  const partFiles = Array.from({ length: total }, (_, i) => path.join(llmPartsDir, `part.${i}.json`));
131
148
  const { pages } = await mergeLlmParts({
@@ -26,10 +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
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
+ }
33
42
  function resolveShardCount(shards) {
34
43
  if (shards === "auto") {
35
44
  const cores = os.cpus().length || 4;
@@ -102,8 +111,8 @@ async function runSharded(opts) {
102
111
  opts.buildRequest
103
112
  );
104
113
  for (const p of siteData.paths) if (!paths.includes(p)) paths.push(p);
105
- const cmsPathSet = new Set(siteData.paths);
106
- 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));
107
116
  if (!paths.includes("/")) {
108
117
  paths.unshift("/");
109
118
  routerPaths.unshift("/");
@@ -128,15 +137,23 @@ async function runSharded(opts) {
128
137
  appPaths: routerPaths
129
138
  }), "utf8");
130
139
  const start = Date.now();
140
+ const indexPath = path.resolve("dist", "index.html");
141
+ const pristineTemplate = await fs.readFile(indexPath, "utf8");
131
142
  let codes;
132
143
  if (total === 1) {
133
144
  codes = [await runShard(0, 1, [], opts, llmPartsDir, routePartsDir, siteDataFile)];
134
145
  } else if (SEQUENTIAL_SHARDS) {
135
146
  codes = [];
147
+ let renderedRoot = null;
136
148
  for (let index = 0; index < total; index++) {
149
+ await fs.writeFile(indexPath, pristineTemplate, "utf8");
137
150
  codes.push(await runShard(index, total, [], opts, llmPartsDir, routePartsDir, siteDataFile));
151
+ if (index === 0 && codes[index] === 0) {
152
+ renderedRoot = await fs.readFile(indexPath, "utf8");
153
+ }
138
154
  if (codes[index] !== 0) break;
139
155
  }
156
+ if (renderedRoot != null) await fs.writeFile(indexPath, renderedRoot, "utf8");
140
157
  } else {
141
158
  codes = await Promise.all(Array.from({ length: total }, (_, i) => runShard(i, total, [], opts, llmPartsDir, routePartsDir, siteDataFile)));
142
159
  }
@@ -149,7 +166,7 @@ async function runSharded(opts) {
149
166
  }
150
167
  if (process.env.BLOX_SSG_LLM !== "0") {
151
168
  try {
152
- const { mergeLlmParts } = await Promise.resolve().then(() => require("./validate-output-Dku8tCir.cjs")).then((n) => n.llmArtifacts);
169
+ const { mergeLlmParts } = await Promise.resolve().then(() => require("./validate-output-BrUqMZIw.cjs")).then((n) => n.llmArtifacts);
153
170
  const mergeWebsite = website;
154
171
  const partFiles = Array.from({ length: total }, (_, i) => path.join(llmPartsDir, `part.${i}.json`));
155
172
  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-Bg091Bud.cjs"));
144
+ const { runSharded } = await Promise.resolve().then(() => require("../shard-runner-CYE0JuX0.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-DY4hpGdP.js");
143
+ const { runSharded } = await import("../shard-runner-C0zS2ZjC.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;AA+ED;;GAEG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CA6I1E"}
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,CAqJ1E"}
@@ -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.547",
4
+ "version": "1.15.551",
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",