contentbit 1.0.0-rc.1 → 1.0.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/dist/bin.js CHANGED
@@ -14,7 +14,7 @@ var VERSION;
14
14
  var init_version = __esm({
15
15
  "../core/dist/version.js"() {
16
16
  "use strict";
17
- VERSION = "1.0.0-rc.1";
17
+ VERSION = "1.0.0";
18
18
  }
19
19
  });
20
20
 
@@ -8119,6 +8119,83 @@ var init_mdast_util_from_markdown = __esm({
8119
8119
  }
8120
8120
  });
8121
8121
 
8122
+ // ../core/dist/closest.js
8123
+ function closest(target, candidates) {
8124
+ let best;
8125
+ let limit = Math.max(2, Math.floor(target.length / 3));
8126
+ const counts = new Int32Array(128);
8127
+ for (let i = 0; i < target.length; i++)
8128
+ counts[target.charCodeAt(i) & 127]++;
8129
+ const prev = new Int32Array(target.length + limit + 2);
8130
+ const curr = new Int32Array(target.length + limit + 2);
8131
+ for (const candidate of candidates) {
8132
+ if (Math.abs(candidate.length - target.length) > limit)
8133
+ continue;
8134
+ if (unpairedExceeds(counts, target.length, candidate, limit))
8135
+ continue;
8136
+ const distance = distanceWithin(target, candidate, limit, prev, curr);
8137
+ if (distance > limit)
8138
+ continue;
8139
+ best = candidate;
8140
+ if (distance === 0)
8141
+ break;
8142
+ limit = distance - 1;
8143
+ }
8144
+ return best;
8145
+ }
8146
+ function unpairedExceeds(counts, targetLength, b, limit) {
8147
+ const allowed = limit - Math.max(0, targetLength - b.length);
8148
+ let unpaired = 0;
8149
+ let j = 0;
8150
+ while (j < b.length && unpaired <= allowed)
8151
+ if (counts[b.charCodeAt(j++) & 127]-- <= 0)
8152
+ unpaired++;
8153
+ for (let k = 0; k < j; k++)
8154
+ counts[b.charCodeAt(k) & 127]++;
8155
+ return unpaired > allowed;
8156
+ }
8157
+ function distanceWithin(a, b, limit, prevRow, currRow) {
8158
+ const over = limit + 1;
8159
+ const delta = b.length - a.length;
8160
+ const slack = limit - Math.abs(delta) >> 1;
8161
+ const low = Math.min(0, delta) - slack;
8162
+ const high = Math.max(0, delta) + slack;
8163
+ let prev = prevRow;
8164
+ let curr = currRow;
8165
+ for (let j = 0; j <= Math.min(b.length, high); j++)
8166
+ prev[j] = j;
8167
+ if (high < b.length)
8168
+ prev[high + 1] = over;
8169
+ for (let i = 1; i <= a.length; i++) {
8170
+ const lo = Math.max(1, i + low);
8171
+ const hi = Math.min(b.length, i + high);
8172
+ const ai = a.charCodeAt(i - 1);
8173
+ curr[lo - 1] = lo === 1 ? i : over;
8174
+ let rowBest = lo === 1 ? i + Math.abs(delta + i) : over;
8175
+ for (let j = lo; j <= hi; j++) {
8176
+ const cost = ai === b.charCodeAt(j - 1) ? 0 : 1;
8177
+ const d = Math.min(prev[j - 1] + cost, prev[j] + 1, curr[j - 1] + 1);
8178
+ curr[j] = d;
8179
+ const finish = d + Math.abs(delta - j + i);
8180
+ if (finish < rowBest)
8181
+ rowBest = finish;
8182
+ }
8183
+ if (rowBest > limit)
8184
+ return over;
8185
+ if (hi < b.length)
8186
+ curr[hi + 1] = over;
8187
+ const done = prev;
8188
+ prev = curr;
8189
+ curr = done;
8190
+ }
8191
+ return Math.min(prev[b.length], over);
8192
+ }
8193
+ var init_closest = __esm({
8194
+ "../core/dist/closest.js"() {
8195
+ "use strict";
8196
+ }
8197
+ });
8198
+
8122
8199
  // ../core/dist/validate.js
8123
8200
  function isValidatedDocument(document3) {
8124
8201
  return document3.__contentbitValidatedDocument === true;
@@ -8196,30 +8273,6 @@ function reportUnknownProps(node2, def, report) {
8196
8273
  }
8197
8274
  return valid;
8198
8275
  }
8199
- function editDistance(a, b) {
8200
- const dp = Array.from({ length: a.length + 1 }, (_, i) => [i, ...Array(b.length).fill(0)]);
8201
- for (let j = 0; j <= b.length; j++)
8202
- dp[0][j] = j;
8203
- for (let i = 1; i <= a.length; i++) {
8204
- for (let j = 1; j <= b.length; j++) {
8205
- const cost = a[i - 1] === b[j - 1] ? 0 : 1;
8206
- dp[i][j] = Math.min(dp[i - 1][j] + 1, dp[i][j - 1] + 1, dp[i - 1][j - 1] + cost);
8207
- }
8208
- }
8209
- return dp[a.length][b.length];
8210
- }
8211
- function closest(target, candidates) {
8212
- let best;
8213
- let bestD = Infinity;
8214
- for (const candidate of candidates) {
8215
- const distance = editDistance(target, candidate);
8216
- if (distance < bestD) {
8217
- bestD = distance;
8218
- best = candidate;
8219
- }
8220
- }
8221
- return best && bestD <= Math.max(2, Math.floor(target.length / 3)) ? best : void 0;
8222
- }
8223
8276
  function validateDocument(parsed, registry2, options = {}) {
8224
8277
  const opts = {
8225
8278
  unknownBlocks: options.unknownBlocks ?? "error",
@@ -8343,6 +8396,7 @@ var init_validate = __esm({
8343
8396
  "../core/dist/validate.js"() {
8344
8397
  "use strict";
8345
8398
  init_mdast_util_from_markdown();
8399
+ init_closest();
8346
8400
  HAS_SCHEME_RE = /^[a-zA-Z][a-zA-Z0-9+.-]*:/;
8347
8401
  MAY_LINK_RE = /\]\(|\]:|</;
8348
8402
  }
@@ -23754,6 +23808,7 @@ function analyzeLinks(inputs, options = {}) {
23754
23808
  const ambiguousPageKeys = ambiguousValidationPageKeys(validInputs, resolvedOptions);
23755
23809
  const index2 = indexLinkPages(validInputs, resolvedOptions);
23756
23810
  const lookup = buildLookup(index2.pages, resolvedOptions);
23811
+ const hintFor = linkHints(lookup, resolvedOptions);
23757
23812
  for (const { fm } of validInputs) {
23758
23813
  const mapKey = pageMapKey(frontmatterIdentity(fm, resolvedOptions), resolvedOptions);
23759
23814
  if (ambiguousPageKeys.has(mapKey))
@@ -23780,7 +23835,7 @@ function analyzeLinks(inputs, options = {}) {
23780
23835
  out.push(diag(page.path, "CB_LINK_LOCALE_MISSING", "error", `linksTo "${resolved.target}" exists in another locale but not "${page.locale ?? "default"}"`, void 0, resolved.target));
23781
23836
  continue;
23782
23837
  }
23783
- const hint = closest2(resolved.target, candidatesFor(page.locale, lookup, resolvedOptions));
23838
+ const hint = hintFor(resolved.target, page.locale);
23784
23839
  out.push(diag(page.path, "CB_LINK_UNRESOLVED", "error", `linksTo "${resolved.target}" does not resolve to any page`, hint ? `Did you mean "${hint}"?` : void 0, resolved.target));
23785
23840
  }
23786
23841
  }
@@ -23944,6 +23999,23 @@ function targetExistsOutsideLocale(target, locale, lookup, options) {
23944
23999
  const byIdentity = usesKeyResolution(options) ? lookup.byKey : lookup.bySlug;
23945
24000
  return (byIdentity.get(target) ?? []).some((page) => page.locale !== locale);
23946
24001
  }
24002
+ function linkHints(lookup, options) {
24003
+ const candidates = /* @__PURE__ */ new Map();
24004
+ const hints = /* @__PURE__ */ new Map();
24005
+ return (target, locale) => {
24006
+ const key = scopedKey(target, locale, options);
24007
+ if (hints.has(key))
24008
+ return hints.get(key);
24009
+ let names = candidates.get(locale);
24010
+ if (!names) {
24011
+ names = candidatesFor(locale, lookup, options);
24012
+ candidates.set(locale, names);
24013
+ }
24014
+ const hint = closest(target, names);
24015
+ hints.set(key, hint);
24016
+ return hint;
24017
+ };
24018
+ }
23947
24019
  function candidatesFor(locale, lookup, options) {
23948
24020
  if (options.resolve === "global-slug")
23949
24021
  return [...lookup.bySlug.keys()];
@@ -23957,35 +24029,12 @@ function candidatesFor(locale, lookup, options) {
23957
24029
  function diag(file2, code2, severity, message, hint, target) {
23958
24030
  return { file: file2, diagnostic: { code: code2, severity, message, hint, position: FM_POSITION }, target };
23959
24031
  }
23960
- function editDistance2(a, b) {
23961
- const dp = Array.from({ length: a.length + 1 }, (_, i) => [i, ...Array(b.length).fill(0)]);
23962
- for (let j = 0; j <= b.length; j++)
23963
- dp[0][j] = j;
23964
- for (let i = 1; i <= a.length; i++) {
23965
- for (let j = 1; j <= b.length; j++) {
23966
- const cost = a[i - 1] === b[j - 1] ? 0 : 1;
23967
- dp[i][j] = Math.min(dp[i - 1][j] + 1, dp[i][j - 1] + 1, dp[i - 1][j - 1] + cost);
23968
- }
23969
- }
23970
- return dp[a.length][b.length];
23971
- }
23972
- function closest2(target, candidates) {
23973
- let best;
23974
- let bestD = Infinity;
23975
- for (const c of candidates) {
23976
- const d = editDistance2(target, c);
23977
- if (d < bestD) {
23978
- bestD = d;
23979
- best = c;
23980
- }
23981
- }
23982
- return best && bestD <= Math.max(2, Math.floor(target.length / 3)) ? best : void 0;
23983
- }
23984
24032
  var LinkTarget, LinkIdentity, LinksTo, Aliases, DEFAULT_OPTIONS, FM_POSITION;
23985
24033
  var init_links = __esm({
23986
24034
  "../core/dist/links.js"() {
23987
24035
  "use strict";
23988
24036
  init_zod();
24037
+ init_closest();
23989
24038
  init_page_facts();
23990
24039
  LinkTarget = external_exports.union([
23991
24040
  external_exports.string(),
@@ -24428,6 +24477,52 @@ var init_seo = __esm({
24428
24477
  }
24429
24478
  });
24430
24479
 
24480
+ // ../core/dist/page-routes.js
24481
+ function contentPageUrlResolver(options) {
24482
+ if (!options.routes)
24483
+ return void 0;
24484
+ const routes = Object.entries(options.routes).map(([dir, url2]) => {
24485
+ for (const [, name] of url2.matchAll(PLACEHOLDER_RE)) {
24486
+ if (!PLACEHOLDERS.includes(name)) {
24487
+ const known = PLACEHOLDERS.map((placeholder) => `{${placeholder}}`).join(", ");
24488
+ throw new Error(`links.routes pattern "${url2}" uses unknown placeholder {${name}}. Use one of ${known}.`);
24489
+ }
24490
+ }
24491
+ return { dir: normalizePath2(dir).replace(/\/$/, ""), url: url2 };
24492
+ }).sort((a, b) => b.dir.length - a.dir.length);
24493
+ return (path4, facts) => {
24494
+ const file2 = normalizePath2(path4);
24495
+ const route = routes.find(({ dir }) => file2.startsWith(`${dir}/`));
24496
+ if (!route)
24497
+ return void 0;
24498
+ const values = {
24499
+ path: file2.slice(route.dir.length + 1).replace(/\.mdx?$/i, "").replace(/(^|\/)index$/, ""),
24500
+ slug: facts.slug,
24501
+ key: facts.key,
24502
+ locale: facts.locale ?? options.defaultLocale
24503
+ };
24504
+ let complete = true;
24505
+ const url2 = route.url.replace(PLACEHOLDER_RE, (_, name) => {
24506
+ const value = values[name];
24507
+ if (value === void 0)
24508
+ complete = false;
24509
+ return value ?? "";
24510
+ });
24511
+ return complete ? url2 : void 0;
24512
+ };
24513
+ }
24514
+ function normalizePath2(path4) {
24515
+ return path4.replaceAll("\\", "/").replace(/\/+/g, "/").replace(/^\.\//, "");
24516
+ }
24517
+ var PLACEHOLDER_RE, PLACEHOLDERS;
24518
+ var init_page_routes = __esm({
24519
+ "../core/dist/page-routes.js"() {
24520
+ "use strict";
24521
+ PLACEHOLDER_RE = /\{([^{}]*)\}/g;
24522
+ PLACEHOLDERS = ["path", "slug", "key", "locale"];
24523
+ }
24524
+ });
24525
+
24431
24526
  // ../core/dist/content-integrity.js
24432
24527
  function scanContentIntegrity(files, options = {}) {
24433
24528
  const findings = [];
@@ -24435,8 +24530,8 @@ function scanContentIntegrity(files, options = {}) {
24435
24530
  file: file2,
24436
24531
  facts: readContentPageFacts(file2.frontmatter, options)
24437
24532
  }));
24438
- const byPath = new Map(files.map((file2) => [normalizePath2(file2.path), file2]));
24439
- const byRoute = routeIndex(pages);
24533
+ const byPath = new Map(files.map((file2) => [normalizePath3(file2.path), file2]));
24534
+ const routes = routeTable(pages, options);
24440
24535
  const titles = /* @__PURE__ */ new Map();
24441
24536
  const descriptions = /* @__PURE__ */ new Map();
24442
24537
  for (const page of pages) {
@@ -24447,7 +24542,7 @@ function scanContentIntegrity(files, options = {}) {
24447
24542
  findings.push(...localeKeyFindings(pages, options));
24448
24543
  for (const file2 of files) {
24449
24544
  for (const link of file2.stats.links.items) {
24450
- const target = resolveContentLink(link.url, file2.path, byRoute);
24545
+ const target = resolveContentLink(link.url, file2.path, routes);
24451
24546
  if (!target)
24452
24547
  continue;
24453
24548
  const destination = byPath.get(target.path);
@@ -24461,7 +24556,7 @@ function scanContentIntegrity(files, options = {}) {
24461
24556
  line: link.line,
24462
24557
  column: 1,
24463
24558
  message: `${label} "${link.url}" does not match a scanned content page`,
24464
- hint: "Use a known page slug, a relative .md/.mdx path, or update the link target."
24559
+ hint: unresolvedLinkHint(target.kind, routes.configured)
24465
24560
  });
24466
24561
  continue;
24467
24562
  }
@@ -24480,6 +24575,15 @@ function scanContentIntegrity(files, options = {}) {
24480
24575
  }
24481
24576
  return findings;
24482
24577
  }
24578
+ function unresolvedLinkHint(kind, routesConfigured) {
24579
+ if (kind === "markdown") {
24580
+ return "Use a known page slug, a relative .md/.mdx path, or update the link target.";
24581
+ }
24582
+ if (routesConfigured) {
24583
+ return "Link to a page URL from links.routes, a route in links.hostRoutes, or a relative .md/.mdx path.";
24584
+ }
24585
+ return "Use a known page slug, a relative .md/.mdx path, or update the link target. If the site serves this URL, describe its routes with links.routes or links.hostRoutes.";
24586
+ }
24483
24587
  function localeKeyFindings(pages, options) {
24484
24588
  const keyField = options.keyField ?? "key";
24485
24589
  const locales = new Set(pages.map(({ facts }) => normalizedFact(facts.locale)).filter(isDefined));
@@ -24586,7 +24690,7 @@ function documentStructureFindings({ file: file2, facts }) {
24586
24690
  }
24587
24691
  return findings;
24588
24692
  }
24589
- function resolveContentLink(url2, sourcePath, byRoute) {
24693
+ function resolveContentLink(url2, sourcePath, routes) {
24590
24694
  if (url2 === "" || /^[a-z][a-z\d+.-]*:/i.test(url2) || url2.startsWith("//")) {
24591
24695
  return void 0;
24592
24696
  }
@@ -24595,7 +24699,7 @@ function resolveContentLink(url2, sourcePath, byRoute) {
24595
24699
  const rawAnchor = hash2 === -1 ? void 0 : url2.slice(hash2 + 1).split("?", 1)[0];
24596
24700
  const anchor = rawAnchor ? decodeUriComponent(rawAnchor) : void 0;
24597
24701
  if (rawPath === "") {
24598
- return { path: normalizePath2(sourcePath), ...anchor ? { anchor } : {}, kind: "markdown" };
24702
+ return { path: normalizePath3(sourcePath), ...anchor ? { anchor } : {}, kind: "markdown" };
24599
24703
  }
24600
24704
  const decodedPath = decodeUriComponent(rawPath);
24601
24705
  if (isRelativeMarkdownPath(decodedPath)) {
@@ -24607,10 +24711,12 @@ function resolveContentLink(url2, sourcePath, byRoute) {
24607
24711
  }
24608
24712
  if (hasFileExtension(decodedPath))
24609
24713
  return void 0;
24714
+ if (routes.configured && !rawPath.startsWith("/"))
24715
+ return void 0;
24610
24716
  const route = normalizeRoute(rawPath);
24611
- if (!route)
24717
+ if (!route || routes.host.has(route))
24612
24718
  return void 0;
24613
- const destination = routeTarget(route, byRoute);
24719
+ const destination = routes.configured ? routes.pages.get(route) : slugTarget(route, routes.pages);
24614
24720
  return {
24615
24721
  path: destination?.path ?? `\0${route}`,
24616
24722
  ...anchor ? { anchor } : {},
@@ -24623,18 +24729,24 @@ function isRelativeMarkdownPath(value) {
24623
24729
  function hasFileExtension(value) {
24624
24730
  return /\/[^/]+\.[a-z\d]+$/i.test(`/${value}`);
24625
24731
  }
24626
- function routeIndex(pages) {
24732
+ function routeTable(pages, options) {
24733
+ const pageUrl = contentPageUrlResolver(options);
24627
24734
  const out = /* @__PURE__ */ new Map();
24628
24735
  for (const { file: file2, facts } of pages) {
24629
- for (const value of [normalizedFact(facts.slug), normalizedFact(facts.key)]) {
24736
+ const urls = pageUrl ? [pageUrl(file2.path, facts)] : [normalizedFact(facts.slug), normalizedFact(facts.key)];
24737
+ for (const value of urls) {
24630
24738
  if (value)
24631
24739
  out.set(normalizeRoute(value), file2);
24632
24740
  }
24633
24741
  }
24634
- return out;
24742
+ return {
24743
+ pages: out,
24744
+ host: new Set((options.hostRoutes ?? []).map(normalizeRoute)),
24745
+ configured: pageUrl !== void 0
24746
+ };
24635
24747
  }
24636
- function routeTarget(route, byRoute) {
24637
- return byRoute.get(route) ?? byRoute.get(route.slice(route.lastIndexOf("/") + 1));
24748
+ function slugTarget(route, bySlug) {
24749
+ return bySlug.get(route) ?? bySlug.get(route.slice(route.lastIndexOf("/") + 1));
24638
24750
  }
24639
24751
  function normalizeRoute(value) {
24640
24752
  return decodeUriComponent(value).replace(/^\.\//, "").replace(/^\/+|\/+$/g, "");
@@ -24658,7 +24770,7 @@ function normalizedFact(value) {
24658
24770
  return value?.trim().replace(/\s+/g, " ").toLocaleLowerCase();
24659
24771
  }
24660
24772
  function dirname(path4) {
24661
- const normalized = normalizePath2(path4);
24773
+ const normalized = normalizePath3(path4);
24662
24774
  const index2 = normalized.lastIndexOf("/");
24663
24775
  return index2 <= 0 ? normalized.startsWith("/") ? "/" : "" : normalized.slice(0, index2);
24664
24776
  }
@@ -24676,7 +24788,7 @@ function joinPath(base, target) {
24676
24788
  }
24677
24789
  return `${absolute || base.startsWith("/") ? "/" : ""}${normalized.join("/")}`;
24678
24790
  }
24679
- function normalizePath2(path4) {
24791
+ function normalizePath3(path4) {
24680
24792
  return joinPath("", path4.replaceAll("\\", "/"));
24681
24793
  }
24682
24794
  function decodeUriComponent(value) {
@@ -24694,6 +24806,7 @@ var init_content_integrity = __esm({
24694
24806
  "../core/dist/content-integrity.js"() {
24695
24807
  "use strict";
24696
24808
  init_page_facts();
24809
+ init_page_routes();
24697
24810
  SLUG_REMOVED_RE = /[^\p{Alphabetic}\p{M}\p{Nd}\p{Pc} -]/gu;
24698
24811
  }
24699
24812
  });
@@ -25054,16 +25167,16 @@ function pathSegments(path4) {
25054
25167
  return path4.split("/").filter(Boolean);
25055
25168
  }
25056
25169
  function projectRelativePath(path4, root) {
25057
- const normalizedPath = normalizePath3(path4);
25170
+ const normalizedPath = normalizePath4(path4);
25058
25171
  if (!root)
25059
25172
  return trimRelativePrefix(normalizedPath);
25060
- const normalizedRoot = normalizePath3(root).replace(/\/$/, "");
25173
+ const normalizedRoot = normalizePath4(root).replace(/\/$/, "");
25061
25174
  if (normalizedPath.startsWith(`${normalizedRoot}/`)) {
25062
25175
  return normalizedPath.slice(normalizedRoot.length + 1);
25063
25176
  }
25064
25177
  return trimRelativePrefix(normalizedPath);
25065
25178
  }
25066
- function normalizePath3(path4) {
25179
+ function normalizePath4(path4) {
25067
25180
  return path4.replaceAll("\\", "/").replace(/\/+/g, "/");
25068
25181
  }
25069
25182
  function trimRelativePrefix(path4) {
@@ -26520,7 +26633,7 @@ var init_option = __esm({
26520
26633
  });
26521
26634
 
26522
26635
  // ../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/suggestSimilar.js
26523
- function editDistance3(a, b) {
26636
+ function editDistance(a, b) {
26524
26637
  if (Math.abs(a.length - b.length) > maxDistance)
26525
26638
  return Math.max(a.length, b.length);
26526
26639
  const d = [];
@@ -26566,7 +26679,7 @@ function suggestSimilar(word, candidates) {
26566
26679
  const minSimilarity = 0.4;
26567
26680
  candidates.forEach((candidate) => {
26568
26681
  if (candidate.length <= 1) return;
26569
- const distance = editDistance3(word, candidate);
26682
+ const distance = editDistance(word, candidate);
26570
26683
  const length = Math.max(word.length, candidate.length);
26571
26684
  const similarity = (length - distance) / length;
26572
26685
  if (similarity > minSimilarity) {
@@ -30695,6 +30808,10 @@ async function resolveContentCommandConfig(command, input, startDir = process.cw
30695
30808
  keyField: input.keyField ?? defaults.keyField,
30696
30809
  defaultLocale: input.defaultLocale ?? defaults.defaultLocale
30697
30810
  };
30811
+ const routes = {
30812
+ ...defaults.routes ? { routes: defaults.routes } : {},
30813
+ ...defaults.hostRoutes ? { hostRoutes: defaults.hostRoutes } : {}
30814
+ };
30698
30815
  const seo = {
30699
30816
  cwd: defaults.cwd,
30700
30817
  seoConfig: resolvePath(startDir, input.seoConfig) ?? defaults.seoConfig,
@@ -30705,7 +30822,7 @@ async function resolveContentCommandConfig(command, input, startDir = process.cw
30705
30822
  cwd: defaults.cwd,
30706
30823
  registry: resolvePath(startDir, input.registry) ?? defaults.registry,
30707
30824
  includeGenericBlocks: !(input.noGenericBlocks || defaults.noGenericBlocks),
30708
- resolveLinkOptions: () => linkResolverOptions(links),
30825
+ resolveLinkOptions: () => ({ ...linkResolverOptions(links), ...routes }),
30709
30826
  loadSeo: () => loadSeoConfig(seo)
30710
30827
  };
30711
30828
  }
@@ -30722,6 +30839,8 @@ async function discoverContentCommandDefaults(command, explicitGlobs, startDir =
30722
30839
  slugField: loadedConfig.config.links?.slugField,
30723
30840
  keyField: loadedConfig.config.links?.keyField,
30724
30841
  defaultLocale: loadedConfig.config.links?.defaultLocale,
30842
+ routes: resolveRouteDirs(loadedConfig.cwd, loadedConfig.config.links?.routes),
30843
+ hostRoutes: loadedConfig.config.links?.hostRoutes,
30725
30844
  source: loadedConfig.path
30726
30845
  } : {};
30727
30846
  if (explicitGlobs.length > 0) return { ...configDefaults, cwd: void 0, globs: explicitGlobs };
@@ -30740,6 +30859,10 @@ async function discoverContentCommandDefaults(command, explicitGlobs, startDir =
30740
30859
  function resolvePath(base, path4) {
30741
30860
  return path4 ? resolve3(base, path4) : void 0;
30742
30861
  }
30862
+ function resolveRouteDirs(base, routes) {
30863
+ if (!routes) return void 0;
30864
+ return Object.fromEntries(Object.entries(routes).map(([dir, url2]) => [resolve3(base, dir), url2]));
30865
+ }
30743
30866
  async function findPackageScript(command, startDir) {
30744
30867
  let current = resolve3(startDir);
30745
30868
  while (true) {
@@ -1 +1 @@
1
- {"version":3,"file":"command-config.d.ts","sourceRoot":"","sources":["../src/command-config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAE3D,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAE9E,OAAO,EAAiB,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAYrE,KAAK,cAAc,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,UAAU,CAAA;AAEjG,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC7D,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,WAAW,4BAA4B;IAC3C,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,oBAAoB,EAAE,OAAO,CAAA;IAC7B,kBAAkB,IAAI,mBAAmB,CAAA;IACzC,OAAO,IAAI,OAAO,CAAC,eAAe,CAAC,CAAA;CACpC;AAED;;wEAEwE;AACxE,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,qBAAqB,EAC5B,QAAQ,SAAgB,GACvB,OAAO,CAAC,4BAA4B,CAAC,CAwBvC"}
1
+ {"version":3,"file":"command-config.d.ts","sourceRoot":"","sources":["../src/command-config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAE3D,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAE9E,OAAO,EAAiB,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAcrE,KAAK,cAAc,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,UAAU,CAAA;AAEjG,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC7D,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,WAAW,4BAA4B;IAC3C,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,oBAAoB,EAAE,OAAO,CAAA;IAC7B,kBAAkB,IAAI,mBAAmB,CAAA;IACzC,OAAO,IAAI,OAAO,CAAC,eAAe,CAAC,CAAA;CACpC;AAED;;wEAEwE;AACxE,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,qBAAqB,EAC5B,QAAQ,SAAgB,GACvB,OAAO,CAAC,4BAA4B,CAAC,CA4BvC"}
package/dist/run.js CHANGED
@@ -13,7 +13,7 @@ var VERSION;
13
13
  var init_version = __esm({
14
14
  "../core/dist/version.js"() {
15
15
  "use strict";
16
- VERSION = "1.0.0-rc.1";
16
+ VERSION = "1.0.0";
17
17
  }
18
18
  });
19
19
 
@@ -8118,6 +8118,83 @@ var init_mdast_util_from_markdown = __esm({
8118
8118
  }
8119
8119
  });
8120
8120
 
8121
+ // ../core/dist/closest.js
8122
+ function closest(target, candidates) {
8123
+ let best;
8124
+ let limit = Math.max(2, Math.floor(target.length / 3));
8125
+ const counts = new Int32Array(128);
8126
+ for (let i = 0; i < target.length; i++)
8127
+ counts[target.charCodeAt(i) & 127]++;
8128
+ const prev = new Int32Array(target.length + limit + 2);
8129
+ const curr = new Int32Array(target.length + limit + 2);
8130
+ for (const candidate of candidates) {
8131
+ if (Math.abs(candidate.length - target.length) > limit)
8132
+ continue;
8133
+ if (unpairedExceeds(counts, target.length, candidate, limit))
8134
+ continue;
8135
+ const distance = distanceWithin(target, candidate, limit, prev, curr);
8136
+ if (distance > limit)
8137
+ continue;
8138
+ best = candidate;
8139
+ if (distance === 0)
8140
+ break;
8141
+ limit = distance - 1;
8142
+ }
8143
+ return best;
8144
+ }
8145
+ function unpairedExceeds(counts, targetLength, b, limit) {
8146
+ const allowed = limit - Math.max(0, targetLength - b.length);
8147
+ let unpaired = 0;
8148
+ let j = 0;
8149
+ while (j < b.length && unpaired <= allowed)
8150
+ if (counts[b.charCodeAt(j++) & 127]-- <= 0)
8151
+ unpaired++;
8152
+ for (let k = 0; k < j; k++)
8153
+ counts[b.charCodeAt(k) & 127]++;
8154
+ return unpaired > allowed;
8155
+ }
8156
+ function distanceWithin(a, b, limit, prevRow, currRow) {
8157
+ const over = limit + 1;
8158
+ const delta = b.length - a.length;
8159
+ const slack = limit - Math.abs(delta) >> 1;
8160
+ const low = Math.min(0, delta) - slack;
8161
+ const high = Math.max(0, delta) + slack;
8162
+ let prev = prevRow;
8163
+ let curr = currRow;
8164
+ for (let j = 0; j <= Math.min(b.length, high); j++)
8165
+ prev[j] = j;
8166
+ if (high < b.length)
8167
+ prev[high + 1] = over;
8168
+ for (let i = 1; i <= a.length; i++) {
8169
+ const lo = Math.max(1, i + low);
8170
+ const hi = Math.min(b.length, i + high);
8171
+ const ai = a.charCodeAt(i - 1);
8172
+ curr[lo - 1] = lo === 1 ? i : over;
8173
+ let rowBest = lo === 1 ? i + Math.abs(delta + i) : over;
8174
+ for (let j = lo; j <= hi; j++) {
8175
+ const cost = ai === b.charCodeAt(j - 1) ? 0 : 1;
8176
+ const d = Math.min(prev[j - 1] + cost, prev[j] + 1, curr[j - 1] + 1);
8177
+ curr[j] = d;
8178
+ const finish = d + Math.abs(delta - j + i);
8179
+ if (finish < rowBest)
8180
+ rowBest = finish;
8181
+ }
8182
+ if (rowBest > limit)
8183
+ return over;
8184
+ if (hi < b.length)
8185
+ curr[hi + 1] = over;
8186
+ const done = prev;
8187
+ prev = curr;
8188
+ curr = done;
8189
+ }
8190
+ return Math.min(prev[b.length], over);
8191
+ }
8192
+ var init_closest = __esm({
8193
+ "../core/dist/closest.js"() {
8194
+ "use strict";
8195
+ }
8196
+ });
8197
+
8121
8198
  // ../core/dist/validate.js
8122
8199
  function isValidatedDocument(document3) {
8123
8200
  return document3.__contentbitValidatedDocument === true;
@@ -8195,30 +8272,6 @@ function reportUnknownProps(node2, def, report) {
8195
8272
  }
8196
8273
  return valid;
8197
8274
  }
8198
- function editDistance(a, b) {
8199
- const dp = Array.from({ length: a.length + 1 }, (_, i) => [i, ...Array(b.length).fill(0)]);
8200
- for (let j = 0; j <= b.length; j++)
8201
- dp[0][j] = j;
8202
- for (let i = 1; i <= a.length; i++) {
8203
- for (let j = 1; j <= b.length; j++) {
8204
- const cost = a[i - 1] === b[j - 1] ? 0 : 1;
8205
- dp[i][j] = Math.min(dp[i - 1][j] + 1, dp[i][j - 1] + 1, dp[i - 1][j - 1] + cost);
8206
- }
8207
- }
8208
- return dp[a.length][b.length];
8209
- }
8210
- function closest(target, candidates) {
8211
- let best;
8212
- let bestD = Infinity;
8213
- for (const candidate of candidates) {
8214
- const distance = editDistance(target, candidate);
8215
- if (distance < bestD) {
8216
- bestD = distance;
8217
- best = candidate;
8218
- }
8219
- }
8220
- return best && bestD <= Math.max(2, Math.floor(target.length / 3)) ? best : void 0;
8221
- }
8222
8275
  function validateDocument(parsed, registry2, options = {}) {
8223
8276
  const opts = {
8224
8277
  unknownBlocks: options.unknownBlocks ?? "error",
@@ -8342,6 +8395,7 @@ var init_validate = __esm({
8342
8395
  "../core/dist/validate.js"() {
8343
8396
  "use strict";
8344
8397
  init_mdast_util_from_markdown();
8398
+ init_closest();
8345
8399
  HAS_SCHEME_RE = /^[a-zA-Z][a-zA-Z0-9+.-]*:/;
8346
8400
  MAY_LINK_RE = /\]\(|\]:|</;
8347
8401
  }
@@ -23753,6 +23807,7 @@ function analyzeLinks(inputs, options = {}) {
23753
23807
  const ambiguousPageKeys = ambiguousValidationPageKeys(validInputs, resolvedOptions);
23754
23808
  const index2 = indexLinkPages(validInputs, resolvedOptions);
23755
23809
  const lookup = buildLookup(index2.pages, resolvedOptions);
23810
+ const hintFor = linkHints(lookup, resolvedOptions);
23756
23811
  for (const { fm } of validInputs) {
23757
23812
  const mapKey = pageMapKey(frontmatterIdentity(fm, resolvedOptions), resolvedOptions);
23758
23813
  if (ambiguousPageKeys.has(mapKey))
@@ -23779,7 +23834,7 @@ function analyzeLinks(inputs, options = {}) {
23779
23834
  out.push(diag(page.path, "CB_LINK_LOCALE_MISSING", "error", `linksTo "${resolved.target}" exists in another locale but not "${page.locale ?? "default"}"`, void 0, resolved.target));
23780
23835
  continue;
23781
23836
  }
23782
- const hint = closest2(resolved.target, candidatesFor(page.locale, lookup, resolvedOptions));
23837
+ const hint = hintFor(resolved.target, page.locale);
23783
23838
  out.push(diag(page.path, "CB_LINK_UNRESOLVED", "error", `linksTo "${resolved.target}" does not resolve to any page`, hint ? `Did you mean "${hint}"?` : void 0, resolved.target));
23784
23839
  }
23785
23840
  }
@@ -23943,6 +23998,23 @@ function targetExistsOutsideLocale(target, locale, lookup, options) {
23943
23998
  const byIdentity = usesKeyResolution(options) ? lookup.byKey : lookup.bySlug;
23944
23999
  return (byIdentity.get(target) ?? []).some((page) => page.locale !== locale);
23945
24000
  }
24001
+ function linkHints(lookup, options) {
24002
+ const candidates = /* @__PURE__ */ new Map();
24003
+ const hints = /* @__PURE__ */ new Map();
24004
+ return (target, locale) => {
24005
+ const key = scopedKey(target, locale, options);
24006
+ if (hints.has(key))
24007
+ return hints.get(key);
24008
+ let names = candidates.get(locale);
24009
+ if (!names) {
24010
+ names = candidatesFor(locale, lookup, options);
24011
+ candidates.set(locale, names);
24012
+ }
24013
+ const hint = closest(target, names);
24014
+ hints.set(key, hint);
24015
+ return hint;
24016
+ };
24017
+ }
23946
24018
  function candidatesFor(locale, lookup, options) {
23947
24019
  if (options.resolve === "global-slug")
23948
24020
  return [...lookup.bySlug.keys()];
@@ -23956,35 +24028,12 @@ function candidatesFor(locale, lookup, options) {
23956
24028
  function diag(file2, code, severity, message, hint, target) {
23957
24029
  return { file: file2, diagnostic: { code, severity, message, hint, position: FM_POSITION }, target };
23958
24030
  }
23959
- function editDistance2(a, b) {
23960
- const dp = Array.from({ length: a.length + 1 }, (_, i) => [i, ...Array(b.length).fill(0)]);
23961
- for (let j = 0; j <= b.length; j++)
23962
- dp[0][j] = j;
23963
- for (let i = 1; i <= a.length; i++) {
23964
- for (let j = 1; j <= b.length; j++) {
23965
- const cost = a[i - 1] === b[j - 1] ? 0 : 1;
23966
- dp[i][j] = Math.min(dp[i - 1][j] + 1, dp[i][j - 1] + 1, dp[i - 1][j - 1] + cost);
23967
- }
23968
- }
23969
- return dp[a.length][b.length];
23970
- }
23971
- function closest2(target, candidates) {
23972
- let best;
23973
- let bestD = Infinity;
23974
- for (const c of candidates) {
23975
- const d = editDistance2(target, c);
23976
- if (d < bestD) {
23977
- bestD = d;
23978
- best = c;
23979
- }
23980
- }
23981
- return best && bestD <= Math.max(2, Math.floor(target.length / 3)) ? best : void 0;
23982
- }
23983
24031
  var LinkTarget, LinkIdentity, LinksTo, Aliases, DEFAULT_OPTIONS, FM_POSITION;
23984
24032
  var init_links = __esm({
23985
24033
  "../core/dist/links.js"() {
23986
24034
  "use strict";
23987
24035
  init_zod();
24036
+ init_closest();
23988
24037
  init_page_facts();
23989
24038
  LinkTarget = external_exports.union([
23990
24039
  external_exports.string(),
@@ -24427,6 +24476,52 @@ var init_seo = __esm({
24427
24476
  }
24428
24477
  });
24429
24478
 
24479
+ // ../core/dist/page-routes.js
24480
+ function contentPageUrlResolver(options) {
24481
+ if (!options.routes)
24482
+ return void 0;
24483
+ const routes = Object.entries(options.routes).map(([dir, url2]) => {
24484
+ for (const [, name] of url2.matchAll(PLACEHOLDER_RE)) {
24485
+ if (!PLACEHOLDERS.includes(name)) {
24486
+ const known = PLACEHOLDERS.map((placeholder) => `{${placeholder}}`).join(", ");
24487
+ throw new Error(`links.routes pattern "${url2}" uses unknown placeholder {${name}}. Use one of ${known}.`);
24488
+ }
24489
+ }
24490
+ return { dir: normalizePath2(dir).replace(/\/$/, ""), url: url2 };
24491
+ }).sort((a, b) => b.dir.length - a.dir.length);
24492
+ return (path4, facts) => {
24493
+ const file2 = normalizePath2(path4);
24494
+ const route = routes.find(({ dir }) => file2.startsWith(`${dir}/`));
24495
+ if (!route)
24496
+ return void 0;
24497
+ const values = {
24498
+ path: file2.slice(route.dir.length + 1).replace(/\.mdx?$/i, "").replace(/(^|\/)index$/, ""),
24499
+ slug: facts.slug,
24500
+ key: facts.key,
24501
+ locale: facts.locale ?? options.defaultLocale
24502
+ };
24503
+ let complete = true;
24504
+ const url2 = route.url.replace(PLACEHOLDER_RE, (_, name) => {
24505
+ const value = values[name];
24506
+ if (value === void 0)
24507
+ complete = false;
24508
+ return value ?? "";
24509
+ });
24510
+ return complete ? url2 : void 0;
24511
+ };
24512
+ }
24513
+ function normalizePath2(path4) {
24514
+ return path4.replaceAll("\\", "/").replace(/\/+/g, "/").replace(/^\.\//, "");
24515
+ }
24516
+ var PLACEHOLDER_RE, PLACEHOLDERS;
24517
+ var init_page_routes = __esm({
24518
+ "../core/dist/page-routes.js"() {
24519
+ "use strict";
24520
+ PLACEHOLDER_RE = /\{([^{}]*)\}/g;
24521
+ PLACEHOLDERS = ["path", "slug", "key", "locale"];
24522
+ }
24523
+ });
24524
+
24430
24525
  // ../core/dist/content-integrity.js
24431
24526
  function scanContentIntegrity(files, options = {}) {
24432
24527
  const findings = [];
@@ -24434,8 +24529,8 @@ function scanContentIntegrity(files, options = {}) {
24434
24529
  file: file2,
24435
24530
  facts: readContentPageFacts(file2.frontmatter, options)
24436
24531
  }));
24437
- const byPath = new Map(files.map((file2) => [normalizePath2(file2.path), file2]));
24438
- const byRoute = routeIndex(pages);
24532
+ const byPath = new Map(files.map((file2) => [normalizePath3(file2.path), file2]));
24533
+ const routes = routeTable(pages, options);
24439
24534
  const titles = /* @__PURE__ */ new Map();
24440
24535
  const descriptions = /* @__PURE__ */ new Map();
24441
24536
  for (const page of pages) {
@@ -24446,7 +24541,7 @@ function scanContentIntegrity(files, options = {}) {
24446
24541
  findings.push(...localeKeyFindings(pages, options));
24447
24542
  for (const file2 of files) {
24448
24543
  for (const link of file2.stats.links.items) {
24449
- const target = resolveContentLink(link.url, file2.path, byRoute);
24544
+ const target = resolveContentLink(link.url, file2.path, routes);
24450
24545
  if (!target)
24451
24546
  continue;
24452
24547
  const destination = byPath.get(target.path);
@@ -24460,7 +24555,7 @@ function scanContentIntegrity(files, options = {}) {
24460
24555
  line: link.line,
24461
24556
  column: 1,
24462
24557
  message: `${label} "${link.url}" does not match a scanned content page`,
24463
- hint: "Use a known page slug, a relative .md/.mdx path, or update the link target."
24558
+ hint: unresolvedLinkHint(target.kind, routes.configured)
24464
24559
  });
24465
24560
  continue;
24466
24561
  }
@@ -24479,6 +24574,15 @@ function scanContentIntegrity(files, options = {}) {
24479
24574
  }
24480
24575
  return findings;
24481
24576
  }
24577
+ function unresolvedLinkHint(kind, routesConfigured) {
24578
+ if (kind === "markdown") {
24579
+ return "Use a known page slug, a relative .md/.mdx path, or update the link target.";
24580
+ }
24581
+ if (routesConfigured) {
24582
+ return "Link to a page URL from links.routes, a route in links.hostRoutes, or a relative .md/.mdx path.";
24583
+ }
24584
+ return "Use a known page slug, a relative .md/.mdx path, or update the link target. If the site serves this URL, describe its routes with links.routes or links.hostRoutes.";
24585
+ }
24482
24586
  function localeKeyFindings(pages, options) {
24483
24587
  const keyField = options.keyField ?? "key";
24484
24588
  const locales = new Set(pages.map(({ facts }) => normalizedFact(facts.locale)).filter(isDefined));
@@ -24585,7 +24689,7 @@ function documentStructureFindings({ file: file2, facts }) {
24585
24689
  }
24586
24690
  return findings;
24587
24691
  }
24588
- function resolveContentLink(url2, sourcePath, byRoute) {
24692
+ function resolveContentLink(url2, sourcePath, routes) {
24589
24693
  if (url2 === "" || /^[a-z][a-z\d+.-]*:/i.test(url2) || url2.startsWith("//")) {
24590
24694
  return void 0;
24591
24695
  }
@@ -24594,7 +24698,7 @@ function resolveContentLink(url2, sourcePath, byRoute) {
24594
24698
  const rawAnchor = hash2 === -1 ? void 0 : url2.slice(hash2 + 1).split("?", 1)[0];
24595
24699
  const anchor = rawAnchor ? decodeUriComponent(rawAnchor) : void 0;
24596
24700
  if (rawPath === "") {
24597
- return { path: normalizePath2(sourcePath), ...anchor ? { anchor } : {}, kind: "markdown" };
24701
+ return { path: normalizePath3(sourcePath), ...anchor ? { anchor } : {}, kind: "markdown" };
24598
24702
  }
24599
24703
  const decodedPath = decodeUriComponent(rawPath);
24600
24704
  if (isRelativeMarkdownPath(decodedPath)) {
@@ -24606,10 +24710,12 @@ function resolveContentLink(url2, sourcePath, byRoute) {
24606
24710
  }
24607
24711
  if (hasFileExtension(decodedPath))
24608
24712
  return void 0;
24713
+ if (routes.configured && !rawPath.startsWith("/"))
24714
+ return void 0;
24609
24715
  const route = normalizeRoute(rawPath);
24610
- if (!route)
24716
+ if (!route || routes.host.has(route))
24611
24717
  return void 0;
24612
- const destination = routeTarget(route, byRoute);
24718
+ const destination = routes.configured ? routes.pages.get(route) : slugTarget(route, routes.pages);
24613
24719
  return {
24614
24720
  path: destination?.path ?? `\0${route}`,
24615
24721
  ...anchor ? { anchor } : {},
@@ -24622,18 +24728,24 @@ function isRelativeMarkdownPath(value) {
24622
24728
  function hasFileExtension(value) {
24623
24729
  return /\/[^/]+\.[a-z\d]+$/i.test(`/${value}`);
24624
24730
  }
24625
- function routeIndex(pages) {
24731
+ function routeTable(pages, options) {
24732
+ const pageUrl = contentPageUrlResolver(options);
24626
24733
  const out = /* @__PURE__ */ new Map();
24627
24734
  for (const { file: file2, facts } of pages) {
24628
- for (const value of [normalizedFact(facts.slug), normalizedFact(facts.key)]) {
24735
+ const urls = pageUrl ? [pageUrl(file2.path, facts)] : [normalizedFact(facts.slug), normalizedFact(facts.key)];
24736
+ for (const value of urls) {
24629
24737
  if (value)
24630
24738
  out.set(normalizeRoute(value), file2);
24631
24739
  }
24632
24740
  }
24633
- return out;
24741
+ return {
24742
+ pages: out,
24743
+ host: new Set((options.hostRoutes ?? []).map(normalizeRoute)),
24744
+ configured: pageUrl !== void 0
24745
+ };
24634
24746
  }
24635
- function routeTarget(route, byRoute) {
24636
- return byRoute.get(route) ?? byRoute.get(route.slice(route.lastIndexOf("/") + 1));
24747
+ function slugTarget(route, bySlug) {
24748
+ return bySlug.get(route) ?? bySlug.get(route.slice(route.lastIndexOf("/") + 1));
24637
24749
  }
24638
24750
  function normalizeRoute(value) {
24639
24751
  return decodeUriComponent(value).replace(/^\.\//, "").replace(/^\/+|\/+$/g, "");
@@ -24657,7 +24769,7 @@ function normalizedFact(value) {
24657
24769
  return value?.trim().replace(/\s+/g, " ").toLocaleLowerCase();
24658
24770
  }
24659
24771
  function dirname(path4) {
24660
- const normalized = normalizePath2(path4);
24772
+ const normalized = normalizePath3(path4);
24661
24773
  const index2 = normalized.lastIndexOf("/");
24662
24774
  return index2 <= 0 ? normalized.startsWith("/") ? "/" : "" : normalized.slice(0, index2);
24663
24775
  }
@@ -24675,7 +24787,7 @@ function joinPath(base, target) {
24675
24787
  }
24676
24788
  return `${absolute || base.startsWith("/") ? "/" : ""}${normalized.join("/")}`;
24677
24789
  }
24678
- function normalizePath2(path4) {
24790
+ function normalizePath3(path4) {
24679
24791
  return joinPath("", path4.replaceAll("\\", "/"));
24680
24792
  }
24681
24793
  function decodeUriComponent(value) {
@@ -24693,6 +24805,7 @@ var init_content_integrity = __esm({
24693
24805
  "../core/dist/content-integrity.js"() {
24694
24806
  "use strict";
24695
24807
  init_page_facts();
24808
+ init_page_routes();
24696
24809
  SLUG_REMOVED_RE = /[^\p{Alphabetic}\p{M}\p{Nd}\p{Pc} -]/gu;
24697
24810
  }
24698
24811
  });
@@ -25053,16 +25166,16 @@ function pathSegments(path4) {
25053
25166
  return path4.split("/").filter(Boolean);
25054
25167
  }
25055
25168
  function projectRelativePath(path4, root) {
25056
- const normalizedPath = normalizePath3(path4);
25169
+ const normalizedPath = normalizePath4(path4);
25057
25170
  if (!root)
25058
25171
  return trimRelativePrefix(normalizedPath);
25059
- const normalizedRoot = normalizePath3(root).replace(/\/$/, "");
25172
+ const normalizedRoot = normalizePath4(root).replace(/\/$/, "");
25060
25173
  if (normalizedPath.startsWith(`${normalizedRoot}/`)) {
25061
25174
  return normalizedPath.slice(normalizedRoot.length + 1);
25062
25175
  }
25063
25176
  return trimRelativePrefix(normalizedPath);
25064
25177
  }
25065
- function normalizePath3(path4) {
25178
+ function normalizePath4(path4) {
25066
25179
  return path4.replaceAll("\\", "/").replace(/\/+/g, "/");
25067
25180
  }
25068
25181
  function trimRelativePrefix(path4) {
@@ -26519,7 +26632,7 @@ var init_option = __esm({
26519
26632
  });
26520
26633
 
26521
26634
  // ../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/suggestSimilar.js
26522
- function editDistance3(a, b) {
26635
+ function editDistance(a, b) {
26523
26636
  if (Math.abs(a.length - b.length) > maxDistance)
26524
26637
  return Math.max(a.length, b.length);
26525
26638
  const d = [];
@@ -26565,7 +26678,7 @@ function suggestSimilar(word, candidates) {
26565
26678
  const minSimilarity = 0.4;
26566
26679
  candidates.forEach((candidate) => {
26567
26680
  if (candidate.length <= 1) return;
26568
- const distance = editDistance3(word, candidate);
26681
+ const distance = editDistance(word, candidate);
26569
26682
  const length = Math.max(word.length, candidate.length);
26570
26683
  const similarity = (length - distance) / length;
26571
26684
  if (similarity > minSimilarity) {
@@ -30694,6 +30807,10 @@ async function resolveContentCommandConfig(command, input, startDir = process.cw
30694
30807
  keyField: input.keyField ?? defaults.keyField,
30695
30808
  defaultLocale: input.defaultLocale ?? defaults.defaultLocale
30696
30809
  };
30810
+ const routes = {
30811
+ ...defaults.routes ? { routes: defaults.routes } : {},
30812
+ ...defaults.hostRoutes ? { hostRoutes: defaults.hostRoutes } : {}
30813
+ };
30697
30814
  const seo = {
30698
30815
  cwd: defaults.cwd,
30699
30816
  seoConfig: resolvePath(startDir, input.seoConfig) ?? defaults.seoConfig,
@@ -30704,7 +30821,7 @@ async function resolveContentCommandConfig(command, input, startDir = process.cw
30704
30821
  cwd: defaults.cwd,
30705
30822
  registry: resolvePath(startDir, input.registry) ?? defaults.registry,
30706
30823
  includeGenericBlocks: !(input.noGenericBlocks || defaults.noGenericBlocks),
30707
- resolveLinkOptions: () => linkResolverOptions(links),
30824
+ resolveLinkOptions: () => ({ ...linkResolverOptions(links), ...routes }),
30708
30825
  loadSeo: () => loadSeoConfig(seo)
30709
30826
  };
30710
30827
  }
@@ -30721,6 +30838,8 @@ async function discoverContentCommandDefaults(command, explicitGlobs, startDir =
30721
30838
  slugField: loadedConfig.config.links?.slugField,
30722
30839
  keyField: loadedConfig.config.links?.keyField,
30723
30840
  defaultLocale: loadedConfig.config.links?.defaultLocale,
30841
+ routes: resolveRouteDirs(loadedConfig.cwd, loadedConfig.config.links?.routes),
30842
+ hostRoutes: loadedConfig.config.links?.hostRoutes,
30724
30843
  source: loadedConfig.path
30725
30844
  } : {};
30726
30845
  if (explicitGlobs.length > 0) return { ...configDefaults, cwd: void 0, globs: explicitGlobs };
@@ -30739,6 +30858,10 @@ async function discoverContentCommandDefaults(command, explicitGlobs, startDir =
30739
30858
  function resolvePath(base, path4) {
30740
30859
  return path4 ? resolve3(base, path4) : void 0;
30741
30860
  }
30861
+ function resolveRouteDirs(base, routes) {
30862
+ if (!routes) return void 0;
30863
+ return Object.fromEntries(Object.entries(routes).map(([dir, url2]) => [resolve3(base, dir), url2]));
30864
+ }
30742
30865
  async function findPackageScript(command, startDir) {
30743
30866
  let current = resolve3(startDir);
30744
30867
  while (true) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentbit",
3
- "version": "1.0.0-rc.1",
3
+ "version": "1.0.0",
4
4
  "description": "CLI for Content Blocks: validate, render, and generate LLM authoring instructions from your registry.",
5
5
  "keywords": [
6
6
  "cli",
@@ -39,15 +39,15 @@
39
39
  "commander": "^15.0.0",
40
40
  "import-meta-resolve": "^4.2.0",
41
41
  "tinyglobby": "^0.2.10",
42
- "@contentbit/blocks": "1.0.0-rc.1",
43
- "@contentbit/core": "1.0.0-rc.1"
42
+ "@contentbit/blocks": "1.0.0",
43
+ "@contentbit/core": "1.0.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/node": "^25.0.9",
47
47
  "esbuild": "^0.28.0",
48
48
  "typescript": "^5.9.3",
49
49
  "vitest": "^4.0.17",
50
- "@contentbit/studio": "1.0.0-rc.1"
50
+ "@contentbit/studio": "1.0.0"
51
51
  },
52
52
  "engines": {
53
53
  "node": ">=22.18"