@bagelink/blox 1.15.547 → 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.
- package/dist/{shard-runner-Bg091Bud.cjs → shard-runner-BwSs_Ws5.cjs} +13 -4
- package/dist/{shard-runner-DY4hpGdP.js → shard-runner-C8zwo_6O.js} +13 -4
- package/dist/ssg/cli.cjs +2 -2
- package/dist/ssg/cli.mjs +2 -2
- package/dist/ssg/cms-routes.d.ts +2 -0
- package/dist/ssg/cms-routes.d.ts.map +1 -1
- package/dist/ssg/index.cjs +1 -1
- package/dist/ssg/index.mjs +2 -2
- package/dist/ssg/shard-runner.d.ts.map +1 -1
- package/dist/{validate-output-Dku8tCir.cjs → validate-output-BrUqMZIw.cjs} +10 -7
- package/dist/{validate-output-XdxaXjgE.js → validate-output-CaMwqCa1.js} +10 -7
- package/package.json +1 -1
|
@@ -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-
|
|
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) => !
|
|
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("/");
|
|
@@ -149,7 +158,7 @@ async function runSharded(opts) {
|
|
|
149
158
|
}
|
|
150
159
|
if (process.env.BLOX_SSG_LLM !== "0") {
|
|
151
160
|
try {
|
|
152
|
-
const { mergeLlmParts } = await Promise.resolve().then(() => require("./validate-output-
|
|
161
|
+
const { mergeLlmParts } = await Promise.resolve().then(() => require("./validate-output-BrUqMZIw.cjs")).then((n) => n.llmArtifacts);
|
|
153
162
|
const mergeWebsite = website;
|
|
154
163
|
const partFiles = Array.from({ length: total }, (_, i) => path.join(llmPartsDir, `part.${i}.json`));
|
|
155
164
|
const { pages } = await mergeLlmParts({
|
|
@@ -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-
|
|
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) => !
|
|
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("/");
|
|
@@ -125,7 +134,7 @@ async function runSharded(opts) {
|
|
|
125
134
|
}
|
|
126
135
|
if (process.env.BLOX_SSG_LLM !== "0") {
|
|
127
136
|
try {
|
|
128
|
-
const { mergeLlmParts } = await import("./validate-output-
|
|
137
|
+
const { mergeLlmParts } = await import("./validate-output-CaMwqCa1.js").then((n) => n.A);
|
|
129
138
|
const mergeWebsite = website;
|
|
130
139
|
const partFiles = Array.from({ length: total }, (_, i) => path.join(llmPartsDir, `part.${i}.json`));
|
|
131
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-
|
|
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-
|
|
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-
|
|
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-
|
|
143
|
+
const { runSharded } = await import("../shard-runner-C8zwo_6O.js");
|
|
144
144
|
const code = await runSharded({
|
|
145
145
|
shards: shardsOpt ?? "auto",
|
|
146
146
|
mode,
|
package/dist/ssg/cms-routes.d.ts
CHANGED
|
@@ -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,
|
|
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"}
|
package/dist/ssg/index.cjs
CHANGED
|
@@ -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-
|
|
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");
|
package/dist/ssg/index.mjs
CHANGED
|
@@ -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-
|
|
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-
|
|
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;
|
|
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
|
|
158
|
-
const localePaths = await expandRoutes(apiBase,
|
|
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
|
|
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
|
|
190
|
-
|
|
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
|
|
135
|
-
const localePaths = await expandRoutes(apiBase,
|
|
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
|
|
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
|
|
167
|
-
|
|
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