@bagelink/blox 1.15.220 → 1.15.222

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.
@@ -360,6 +360,7 @@ async function prerender({
360
360
  failFast = false,
361
361
  maxPages = 5e3,
362
362
  concurrency = 6,
363
+ writeSharedAssets = true,
363
364
  mode = "dir",
364
365
  website = null,
365
366
  websiteId = "",
@@ -456,30 +457,32 @@ async function prerender({
456
457
  await Promise.all(workers);
457
458
  }
458
459
  const canonicalBase = (((_a = website == null ? void 0 : website.seo) == null ? void 0 : _a.canonical_base_url) || (website == null ? void 0 : website.domain) || "").replace(/\/$/, "");
459
- const sitemapPaths = rendered.filter((p) => !noindexPaths.has(p));
460
- if (canonicalBase && sitemapPaths.length > 0) {
461
- const sitemap = generateSitemapXml({ renderedPaths: sitemapPaths, canonicalBase, lastmod });
462
- await fs.writeFile(path.join(absClient, "sitemap.xml"), sitemap, "utf8");
463
- const skipped = noindexPaths.size > 0 ? ` (${noindexPaths.size} noindex excluded)` : "";
464
- console.log(` Generated sitemap.xml (${sitemapPaths.length} URLs)${skipped}`);
465
- }
466
- const robotsTxt = generateRobotsTxt({
467
- robotsTxt: website == null ? void 0 : website.robots_txt,
468
- canonicalBase,
469
- noindex: (_b = website == null ? void 0 : website.seo) == null ? void 0 : _b.noindex
470
- });
471
- await fs.writeFile(path.join(absClient, "robots.txt"), robotsTxt, "utf8");
472
- console.log(" Generated robots.txt");
473
- if (redirects.length > 0) {
474
- const redirectsContent = generateNetlifyRedirects(redirects);
475
- const redirectsPath = path.join(absClient, "_redirects");
476
- let existing = "";
477
- try {
478
- existing = await fs.readFile(redirectsPath, "utf8");
479
- } catch {
460
+ if (writeSharedAssets) {
461
+ const sitemapPaths = rendered.filter((p) => !noindexPaths.has(p));
462
+ if (canonicalBase && sitemapPaths.length > 0) {
463
+ const sitemap = generateSitemapXml({ renderedPaths: sitemapPaths, canonicalBase, lastmod });
464
+ await fs.writeFile(path.join(absClient, "sitemap.xml"), sitemap, "utf8");
465
+ const skipped = noindexPaths.size > 0 ? ` (${noindexPaths.size} noindex excluded)` : "";
466
+ console.log(` Generated sitemap.xml (${sitemapPaths.length} URLs)${skipped}`);
467
+ }
468
+ const robotsTxt = generateRobotsTxt({
469
+ robotsTxt: website == null ? void 0 : website.robots_txt,
470
+ canonicalBase,
471
+ noindex: (_b = website == null ? void 0 : website.seo) == null ? void 0 : _b.noindex
472
+ });
473
+ await fs.writeFile(path.join(absClient, "robots.txt"), robotsTxt, "utf8");
474
+ console.log(" Generated robots.txt");
475
+ if (redirects.length > 0) {
476
+ const redirectsContent = generateNetlifyRedirects(redirects);
477
+ const redirectsPath = path.join(absClient, "_redirects");
478
+ let existing = "";
479
+ try {
480
+ existing = await fs.readFile(redirectsPath, "utf8");
481
+ } catch {
482
+ }
483
+ await fs.writeFile(redirectsPath, redirectsContent + existing, "utf8");
484
+ console.log(` Generated _redirects (${redirects.length} rules)`);
480
485
  }
481
- await fs.writeFile(redirectsPath, redirectsContent + existing, "utf8");
482
- console.log(` Generated _redirects (${redirects.length} rules)`);
483
486
  }
484
487
  return {
485
488
  rendered,
@@ -383,6 +383,7 @@ async function prerender({
383
383
  failFast = false,
384
384
  maxPages = 5e3,
385
385
  concurrency = 6,
386
+ writeSharedAssets = true,
386
387
  mode = "dir",
387
388
  website = null,
388
389
  websiteId = "",
@@ -479,30 +480,32 @@ async function prerender({
479
480
  await Promise.all(workers);
480
481
  }
481
482
  const canonicalBase = (((_a = website == null ? void 0 : website.seo) == null ? void 0 : _a.canonical_base_url) || (website == null ? void 0 : website.domain) || "").replace(/\/$/, "");
482
- const sitemapPaths = rendered.filter((p) => !noindexPaths.has(p));
483
- if (canonicalBase && sitemapPaths.length > 0) {
484
- const sitemap = generateSitemapXml({ renderedPaths: sitemapPaths, canonicalBase, lastmod });
485
- await fs.writeFile(path.join(absClient, "sitemap.xml"), sitemap, "utf8");
486
- const skipped = noindexPaths.size > 0 ? ` (${noindexPaths.size} noindex excluded)` : "";
487
- console.log(` Generated sitemap.xml (${sitemapPaths.length} URLs)${skipped}`);
488
- }
489
- const robotsTxt = generateRobotsTxt({
490
- robotsTxt: website == null ? void 0 : website.robots_txt,
491
- canonicalBase,
492
- noindex: (_b = website == null ? void 0 : website.seo) == null ? void 0 : _b.noindex
493
- });
494
- await fs.writeFile(path.join(absClient, "robots.txt"), robotsTxt, "utf8");
495
- console.log(" Generated robots.txt");
496
- if (redirects.length > 0) {
497
- const redirectsContent = generateNetlifyRedirects(redirects);
498
- const redirectsPath = path.join(absClient, "_redirects");
499
- let existing = "";
500
- try {
501
- existing = await fs.readFile(redirectsPath, "utf8");
502
- } catch {
483
+ if (writeSharedAssets) {
484
+ const sitemapPaths = rendered.filter((p) => !noindexPaths.has(p));
485
+ if (canonicalBase && sitemapPaths.length > 0) {
486
+ const sitemap = generateSitemapXml({ renderedPaths: sitemapPaths, canonicalBase, lastmod });
487
+ await fs.writeFile(path.join(absClient, "sitemap.xml"), sitemap, "utf8");
488
+ const skipped = noindexPaths.size > 0 ? ` (${noindexPaths.size} noindex excluded)` : "";
489
+ console.log(` Generated sitemap.xml (${sitemapPaths.length} URLs)${skipped}`);
490
+ }
491
+ const robotsTxt = generateRobotsTxt({
492
+ robotsTxt: website == null ? void 0 : website.robots_txt,
493
+ canonicalBase,
494
+ noindex: (_b = website == null ? void 0 : website.seo) == null ? void 0 : _b.noindex
495
+ });
496
+ await fs.writeFile(path.join(absClient, "robots.txt"), robotsTxt, "utf8");
497
+ console.log(" Generated robots.txt");
498
+ if (redirects.length > 0) {
499
+ const redirectsContent = generateNetlifyRedirects(redirects);
500
+ const redirectsPath = path.join(absClient, "_redirects");
501
+ let existing = "";
502
+ try {
503
+ existing = await fs.readFile(redirectsPath, "utf8");
504
+ } catch {
505
+ }
506
+ await fs.writeFile(redirectsPath, redirectsContent + existing, "utf8");
507
+ console.log(` Generated _redirects (${redirects.length} rules)`);
503
508
  }
504
- await fs.writeFile(redirectsPath, redirectsContent + existing, "utf8");
505
- console.log(` Generated _redirects (${redirects.length} rules)`);
506
509
  }
507
510
  return {
508
511
  rendered,
package/dist/ssg/cli.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env bun
2
2
  "use strict";
3
3
  const process = require("node:process");
4
- const prerender = require("../prerender-DQfXe7gk.cjs");
4
+ const prerender = require("../prerender-DQYBvxc_.cjs");
5
5
  function installFetchTimeout() {
6
6
  const ms = Number(process.env.BLOX_SSG_FETCH_TIMEOUT_MS) || 2e4;
7
7
  const original = globalThis.fetch;
@@ -45,12 +45,20 @@ async function main() {
45
45
  const extraPaths = [];
46
46
  let crawl = false;
47
47
  let mode = "production";
48
+ let shardIndex = 0;
49
+ let shardTotal = 1;
48
50
  const excludePaths = ["/_blox_preview"];
49
51
  for (const a of argv) {
50
52
  if (a === "--crawl") {
51
53
  crawl = true;
52
54
  } else if (a === "--no-crawl") {
53
55
  crawl = false;
56
+ } else if (a.startsWith("--shard=")) {
57
+ const [i, n] = a.slice("--shard=".length).split("/").map(Number);
58
+ if (Number.isInteger(i) && Number.isInteger(n) && n > 0 && i >= 0 && i < n) {
59
+ shardIndex = i;
60
+ shardTotal = n;
61
+ }
54
62
  } else if (a === "--help" || a === "-h") {
55
63
  console.log(`
56
64
  blox-ssg — Static Site Generator for @bagelink/blox
@@ -129,6 +137,12 @@ Environment:
129
137
  for (const p of extraPaths) {
130
138
  if (!paths.includes(p)) paths.push(p);
131
139
  }
140
+ if (shardTotal > 1) {
141
+ paths = [...paths].sort();
142
+ paths = paths.filter((_, idx) => idx % shardTotal === shardIndex);
143
+ crawl = false;
144
+ console.log(` Shard ${shardIndex + 1}/${shardTotal}: ${paths.length} paths`);
145
+ }
132
146
  const startTime = Date.now();
133
147
  try {
134
148
  const result = await prerender.prerender({
@@ -143,6 +157,9 @@ Environment:
143
157
  // staging box. Defaults conservative; bump for beefy prod builds.
144
158
  concurrency: Number(process.env.BLOX_SSG_CONCURRENCY) || 4,
145
159
  mode: "file",
160
+ // Only shard 0 writes shared, whole-site assets (sitemap/robots/_redirects)
161
+ // so parallel shards don't race/clobber them.
162
+ writeSharedAssets: shardIndex === 0,
146
163
  website,
147
164
  websiteId,
148
165
  redirects,
package/dist/ssg/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bun
2
2
  import process from "node:process";
3
- import { p as polyfillBloxSsgGlobals, f as fetchCmsSiteData, a as prerender } from "../prerender-CDlP5pQU.js";
3
+ import { p as polyfillBloxSsgGlobals, f as fetchCmsSiteData, a as prerender } from "../prerender-BTRIOCtF.js";
4
4
  function installFetchTimeout() {
5
5
  const ms = Number(process.env.BLOX_SSG_FETCH_TIMEOUT_MS) || 2e4;
6
6
  const original = globalThis.fetch;
@@ -44,12 +44,20 @@ async function main() {
44
44
  const extraPaths = [];
45
45
  let crawl = false;
46
46
  let mode = "production";
47
+ let shardIndex = 0;
48
+ let shardTotal = 1;
47
49
  const excludePaths = ["/_blox_preview"];
48
50
  for (const a of argv) {
49
51
  if (a === "--crawl") {
50
52
  crawl = true;
51
53
  } else if (a === "--no-crawl") {
52
54
  crawl = false;
55
+ } else if (a.startsWith("--shard=")) {
56
+ const [i, n] = a.slice("--shard=".length).split("/").map(Number);
57
+ if (Number.isInteger(i) && Number.isInteger(n) && n > 0 && i >= 0 && i < n) {
58
+ shardIndex = i;
59
+ shardTotal = n;
60
+ }
53
61
  } else if (a === "--help" || a === "-h") {
54
62
  console.log(`
55
63
  blox-ssg — Static Site Generator for @bagelink/blox
@@ -128,6 +136,12 @@ Environment:
128
136
  for (const p of extraPaths) {
129
137
  if (!paths.includes(p)) paths.push(p);
130
138
  }
139
+ if (shardTotal > 1) {
140
+ paths = [...paths].sort();
141
+ paths = paths.filter((_, idx) => idx % shardTotal === shardIndex);
142
+ crawl = false;
143
+ console.log(` Shard ${shardIndex + 1}/${shardTotal}: ${paths.length} paths`);
144
+ }
131
145
  const startTime = Date.now();
132
146
  try {
133
147
  const result = await prerender({
@@ -142,6 +156,9 @@ Environment:
142
156
  // staging box. Defaults conservative; bump for beefy prod builds.
143
157
  concurrency: Number(process.env.BLOX_SSG_CONCURRENCY) || 4,
144
158
  mode: "file",
159
+ // Only shard 0 writes shared, whole-site assets (sitemap/robots/_redirects)
160
+ // so parallel shards don't race/clobber them.
161
+ writeSharedAssets: shardIndex === 0,
145
162
  website,
146
163
  websiteId,
147
164
  redirects,
@@ -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 prerender = require("../prerender-DQfXe7gk.cjs");
25
+ const prerender = require("../prerender-DQYBvxc_.cjs");
26
26
  const ssg_client = require("./client.cjs");
27
27
  const pinia = require("pinia");
28
28
  const vue = require("vue");
@@ -1,5 +1,5 @@
1
- import { b as buildPageHead } from "../prerender-CDlP5pQU.js";
2
- import { c, d, f, g, e, h, i, p, a } from "../prerender-CDlP5pQU.js";
1
+ import { b as buildPageHead } from "../prerender-BTRIOCtF.js";
2
+ import { c, d, f, g, e, h, i, p, a } from "../prerender-BTRIOCtF.js";
3
3
  import { BLOX_STATE_WINDOW_KEY, BLOX_COLLECTIONS_WINDOW_KEY, BLOX_WEBSITE_ID_WINDOW_KEY } from "./client.mjs";
4
4
  import { BLOX_DATA_WINDOW_KEY, BLOX_PAGE_SEO_WINDOW_KEY, getCollectionCache, getEmbeddedWebsiteId, installBloxStateCache, installCollectionCache } from "./client.mjs";
5
5
  import { createPinia } from "pinia";
@@ -12,6 +12,12 @@ export interface PrerenderOptions {
12
12
  maxPages?: number;
13
13
  /** How many pages to render concurrently (default 6). */
14
14
  concurrency?: number;
15
+ /**
16
+ * Write whole-site assets (sitemap.xml, robots.txt, _redirects) after render.
17
+ * Defaults true. Set false on all-but-one shard when running parallel shards
18
+ * against the same `dist`, so they don't race/clobber these single files.
19
+ */
20
+ writeSharedAssets?: boolean;
15
21
  mode?: 'dir' | 'file';
16
22
  /** Website settings for SEO injection. */
17
23
  website?: WebsiteRead | null;
@@ -61,6 +67,6 @@ export interface PrerenderResult {
61
67
  * - Generates sitemap.xml, robots.txt, and _redirects post-render.
62
68
  * - Strips hardcoded SEO tags from template and injects per-page equivalents.
63
69
  */
64
- export declare function prerender({ root, clientOutDir, serverEntry, paths, crawl, excludePaths, failFast, maxPages, concurrency, mode, website, websiteId, redirects, collections, }?: PrerenderOptions): Promise<PrerenderResult>;
70
+ export declare function prerender({ root, clientOutDir, serverEntry, paths, crawl, excludePaths, failFast, maxPages, concurrency, writeSharedAssets, mode, website, websiteId, redirects, collections, }?: PrerenderOptions): Promise<PrerenderResult>;
65
71
  export {};
66
72
  //# sourceMappingURL=prerender.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prerender.d.ts","sourceRoot":"","sources":["../../src/ssg/prerender.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAe1C,KAAK,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAA;AAEhE,MAAM,WAAW,gBAAgB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,YAAY,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,CAAA;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,yDAAyD;IACzD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;IACrB,0CAA0C;IAC1C,OAAO,CAAC,EAA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IAAI,CAAA;IACzC,QAAQ,EAAE,MAAM,CAAA;IAChB,8DAA8D;IAC9D,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CAAA;IAC5B,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAA;CACvC;AAED,MAAM,WAAW,YAAY;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,CAAA;CAChB;AAMD,MAAM,WAAW,eAAe;IAC/B,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,QAAQ,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC,CAAA;IAC7D,eAAe,EAAE,MAAM,CAAA;IACvB,eAAe,EAAE,MAAM,CAAA;CACvB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,SAAS,CAAC,EAC/B,IAAoB,EACpB,YAA4B,EAC5B,WAA0C,EAC1C,KAAU,EACV,KAAY,EACZ,YAAiB,EACjB,QAAgB,EAChB,QAAe,EACf,WAAe,EACf,iBAAwB,EACxB,IAAY,EACZ,OAAc,EACd,SAAc,EACd,SAAc,EACd,WAAgB,GAChB,GAAE,gBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC,CAmKlD"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/blox",
3
3
  "type": "module",
4
- "version": "1.15.220",
4
+ "version": "1.15.222",
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",