blume 1.6.3 → 1.6.5

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.
Files changed (95) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/cli/index.js +308 -50
  3. package/dist/cli/index.js.map +29 -24
  4. package/dist/types/ai/component-markdown.d.ts +14 -0
  5. package/dist/types/core/config-input.d.ts +10 -0
  6. package/dist/types/core/schema.d.ts +4 -1
  7. package/docs/01-quickstart.mdx +2 -2
  8. package/docs/02-deployment.mdx +5 -5
  9. package/docs/{07-faq.mdx → 08-faq.mdx} +7 -7
  10. package/docs/advanced/blog.mdx +3 -3
  11. package/docs/advanced/changelog.mdx +2 -2
  12. package/docs/advanced/custom-pages.mdx +4 -4
  13. package/docs/advanced/meta.ts +1 -1
  14. package/docs/configuration/analytics.mdx +21 -2
  15. package/docs/configuration/ask-ai.mdx +179 -0
  16. package/docs/configuration/index.mdx +8 -7
  17. package/docs/configuration/meta.ts +1 -2
  18. package/docs/configuration/search.mdx +1 -1
  19. package/docs/configuration/theming.mdx +1 -1
  20. package/docs/content/i18n.mdx +7 -1
  21. package/docs/content/index.mdx +1 -1
  22. package/docs/content/navigation.mdx +2 -2
  23. package/docs/content/syntax.mdx +2 -2
  24. package/docs/discoverability/agent-discovery.mdx +196 -0
  25. package/docs/discoverability/index.mdx +48 -0
  26. package/docs/discoverability/json-api.mdx +58 -0
  27. package/docs/discoverability/llms-txt.mdx +68 -0
  28. package/docs/discoverability/markdown.mdx +76 -0
  29. package/docs/discoverability/mcp.mdx +64 -0
  30. package/docs/discoverability/meta.ts +18 -0
  31. package/docs/discoverability/metadata.mdx +82 -0
  32. package/docs/discoverability/open-graph.mdx +113 -0
  33. package/docs/discoverability/rss.mdx +24 -0
  34. package/docs/discoverability/sitemap-and-robots.mdx +95 -0
  35. package/docs/discoverability/structured-data.mdx +51 -0
  36. package/docs/index.mdx +5 -5
  37. package/docs/reference/eval.mdx +1 -1
  38. package/docs/reference/meta.ts +1 -1
  39. package/docs/reference/translate.mdx +1 -0
  40. package/package.json +27 -27
  41. package/src/ai/component-markdown.ts +17 -2
  42. package/src/ai/llms.ts +3 -10
  43. package/src/ai/markdown.ts +3 -10
  44. package/src/ai/openapi-components.ts +123 -0
  45. package/src/ai/serializers.ts +24 -0
  46. package/src/astro/generate.ts +5 -6
  47. package/src/astro/templates.ts +42 -12
  48. package/src/audit/checks/links.ts +1 -8
  49. package/src/audit/checks/llms.ts +5 -4
  50. package/src/audit/redirects.ts +4 -3
  51. package/src/audit/run.ts +6 -8
  52. package/src/audit/url.ts +33 -0
  53. package/src/cli/commands/validate.ts +1 -0
  54. package/src/components/content/Component.astro +60 -59
  55. package/src/components/content/example-pane.ts +6 -0
  56. package/src/components/content/mermaid-element.ts +8 -0
  57. package/src/components/layout/Analytics.astro +20 -1
  58. package/src/components/layout/LocaleLinks.astro +42 -0
  59. package/src/components/layout/PageLayout.astro +5 -3
  60. package/src/components/layout/ReferenceLayout.astro +6 -0
  61. package/src/components/layout/RootLayout.astro +6 -3
  62. package/src/components/layout/analytics-client.ts +2 -1
  63. package/src/components/layout/search-locale.ts +13 -0
  64. package/src/components/openapi/ApiOverview.astro +7 -39
  65. package/src/components/openapi/ApiTagOperations.astro +2 -1
  66. package/src/components/openapi/AsyncApiOperation.astro +8 -5
  67. package/src/components/openapi/Authorization.astro +4 -6
  68. package/src/components/openapi/Bindings.astro +2 -2
  69. package/src/components/openapi/Description.astro +109 -0
  70. package/src/components/openapi/GraphqlFieldsTable.astro +5 -7
  71. package/src/components/openapi/GraphqlOperation.astro +7 -5
  72. package/src/components/openapi/GraphqlType.astro +4 -6
  73. package/src/components/openapi/Operation.astro +3 -2
  74. package/src/components/openapi/ParametersTable.astro +5 -7
  75. package/src/components/openapi/RequestBody.astro +2 -4
  76. package/src/components/openapi/Responses.astro +4 -3
  77. package/src/components/openapi/SchemaProperty.astro +11 -6
  78. package/src/components/openapi/description.ts +91 -0
  79. package/src/core/config-input.ts +10 -0
  80. package/src/core/i18n.ts +13 -2
  81. package/src/core/links.ts +33 -1
  82. package/src/core/locale-links.ts +163 -0
  83. package/src/core/schema.ts +8 -0
  84. package/src/core/sources/normalize.ts +57 -7
  85. package/src/markdown/package-commands.ts +27 -3
  86. package/src/openapi/graphql.ts +29 -0
  87. package/src/openapi/model.ts +69 -0
  88. package/src/openapi/render-mdx.ts +3 -2
  89. package/src/openapi/signature.ts +18 -0
  90. package/src/search/documents.ts +4 -9
  91. package/src/theme/entry.ts +28 -4
  92. package/src/translate/anchors.ts +91 -0
  93. package/src/translate/validate.ts +8 -3
  94. package/docs/configuration/ai.mdx +0 -613
  95. package/docs/configuration/seo.mdx +0 -364
package/dist/cli/index.js CHANGED
@@ -1619,6 +1619,11 @@ var pageSite = (context, page, key) => {
1619
1619
  };
1620
1620
 
1621
1621
  // src/audit/url.ts
1622
+ var serverRoutes = (context) => {
1623
+ const mcp = context.project.config.ai?.mcp;
1624
+ return mcp?.enabled ? [normalizePath(mcp.route)] : [];
1625
+ };
1626
+ var isServed = (context, path) => context.byUrl.has(path) || context.files.has(path) || context.files.has(`${path}/index.html`) || serverRoutes(context).includes(path);
1622
1627
  var NON_HTTP_SCHEME = /^(?!https?:)[a-z][a-z0-9+.-]*:/iu;
1623
1628
  var decodePath = (path) => {
1624
1629
  try {
@@ -2349,7 +2354,6 @@ var buildGraph = (pages, origin, deployBase = "") => {
2349
2354
  var orphanPages = (pages, graph, homeUrl = "/") => pages.filter((page) => page.indexable && page.url !== "/" && page.url !== homeUrl && (graph.contentIn.get(page.url)?.size ?? 0) === 0);
2350
2355
 
2351
2356
  // src/audit/checks/links.ts
2352
- var isServed = (context, path) => context.byUrl.has(path) || context.files.has(path) || context.files.has(`${path}/index.html`);
2353
2357
  var MAGIC_FRAGMENTS = new Set(["", "top"]);
2354
2358
  var anchorResolves = (target, fragment) => {
2355
2359
  if (MAGIC_FRAGMENTS.has(fragment)) {
@@ -2500,7 +2504,7 @@ var llmsChecks = {
2500
2504
  continue;
2501
2505
  }
2502
2506
  listed.add(path);
2503
- if (!context.byUrl.has(path) && !context.files.has(path)) {
2507
+ if (!isServed(context, path)) {
2504
2508
  found.push(finding("BLUME_AUDIT_LLMS_TXT_STALE_ENTRY", { file: llms.file, line: entry.line, url: entry.url }, `llms.txt lists ${path}, which the build does not serve.`));
2505
2509
  }
2506
2510
  }
@@ -4915,6 +4919,7 @@ import { getEntry, render } from "astro:content";
4915
4919
  import type { CollectionKey } from "astro:content";
4916
4920
  import RootLayout from "blume/components/layout/RootLayout.astro";
4917
4921
  import { withBase } from "blume/components/islands/base-path.ts";
4922
+ import { stripBasePath, withBasePath } from "blume/core/base-path.ts";
4918
4923
  import { resolveSlot } from "blume/components/layout/overrides.ts";
4919
4924
  import Accordion from "blume/components/content/Accordion.astro";
4920
4925
  import AccordionItem from "blume/components/content/AccordionItem.astro";
@@ -4951,6 +4956,7 @@ import TypeTable from "blume/components/content/TypeTable.astro";
4951
4956
  import Visibility from "blume/components/content/Visibility.astro";
4952
4957
  import YouTube from "blume/components/content/YouTube.astro";
4953
4958
  import Icon from "blume/components/Icon.astro";
4959
+ import LocaleLinks from "blume/components/layout/LocaleLinks.astro";
4954
4960
  import ApiOverview from "blume/components/openapi/ApiOverview.astro";
4955
4961
  import ApiTagOperations from "blume/components/openapi/ApiTagOperations.astro";
4956
4962
  import Operation from "blume/components/openapi/Operation.astro";
@@ -5138,7 +5144,22 @@ const localeAlternates =
5138
5144
  const defaultAlt = i18n ? (alternates ?? []).find((alt) => alt.locale === i18n.defaultLocale) : null;
5139
5145
  const xDefault = defaultAlt && base ? absolute(defaultAlt.path) : null;
5140
5146
 
5141
- const logicalRoute = i18n ? stripLocale(route, locale) : route;
5147
+ // \`route\` arrives with \`basePath\` already applied, so the locale segment it
5148
+ // carries sits *after* the base (\`/docs/ja/guide\`), while \`localePrefix\` is
5149
+ // base-less (\`/ja\`). Stripping and re-adding a locale therefore happen in
5150
+ // base-less space, with the base re-applied at the end — the same
5151
+ // \`withBasePath(basePath, localizeRoute(...))\` composition the manifest uses to
5152
+ // build every real route. Done in based space, \`stripLocale\` matches nothing
5153
+ // and \`localizeRoute\` prepends a second prefix (\`/ja/docs/ja/guide\`). Only a
5154
+ // switcher entry for a locale with no real translation reaches this fallback:
5155
+ // a partially translated hand-written page for its missing locales, or a
5156
+ // generated reference (which has no \`alternates\` at all) for every locale
5157
+ // but its own.
5158
+ const mountLocalized = (logical: string, codeArg: string) =>
5159
+ withBasePath(data.config.basePath, localizeRoute(logical, codeArg));
5160
+ const logicalRoute = i18n
5161
+ ? stripLocale(stripBasePath(data.config.basePath, route), locale)
5162
+ : route;
5142
5163
  const localeSwitch = i18n
5143
5164
  ? i18n.locales.map((l) => {
5144
5165
  const alt = (alternates ?? []).find((x) => x.locale === l.code);
@@ -5146,7 +5167,7 @@ const localeSwitch = i18n
5146
5167
  code: l.code,
5147
5168
  current: l.code === locale,
5148
5169
  dir: l.dir,
5149
- href: alt ? alt.path : localizeRoute(logicalRoute, l.code),
5170
+ href: alt ? alt.path : mountLocalized(logicalRoute, l.code),
5150
5171
  label: l.label,
5151
5172
  untranslated: !alt,
5152
5173
  };
@@ -5160,12 +5181,9 @@ const localeSwitch = i18n
5160
5181
  // (manifest \`versionAlternates\` paths arrive with the base already applied).
5161
5182
  const versionRootFor = (id: string) => {
5162
5183
  const logical = id ? \`/\${id}\` : "/";
5163
- const localized = i18n ? localizeRoute(logical, locale) : logical;
5164
- const mount = data.config.basePath;
5165
- if (!mount) {
5166
- return localized;
5167
- }
5168
- return localized === "/" ? mount : \`\${mount}\${localized}\`;
5184
+ return i18n
5185
+ ? mountLocalized(logical, locale)
5186
+ : withBasePath(data.config.basePath, logical);
5169
5187
  };
5170
5188
  const samePageSwitch = versionsConfig
5171
5189
  ? versionsConfig.switcher.redirect === "same-page"
@@ -5274,7 +5292,9 @@ const LayoutComponent = resolveSlot(layoutOverrides.Layout, RootLayout);
5274
5292
  >
5275
5293
  <h1>{title}</h1>
5276
5294
  {frontmatter.description && <p class="text-lg text-muted-foreground">{frontmatter.description}</p>}
5277
- <Content components={components} />
5295
+ <LocaleLinks locale={locale}>
5296
+ <Content components={components} />
5297
+ </LocaleLinks>
5278
5298
  </LayoutComponent>
5279
5299
  `;
5280
5300
  };
@@ -5956,7 +5976,7 @@ const Example = entry.Component;
5956
5976
  const bodyStyle = getComputedStyle(document.body);
5957
5977
  const paddingPx =
5958
5978
  parseFloat(bodyStyle.paddingTop) + parseFloat(bodyStyle.paddingBottom);
5959
- new ResizeObserver(() => {
5979
+ const report = () => {
5960
5980
  window.parent.postMessage(
5961
5981
  {
5962
5982
  height:
@@ -5965,7 +5985,19 @@ const Example = entry.Component;
5965
5985
  },
5966
5986
  window.location.origin
5967
5987
  );
5968
- }).observe(wrapper);
5988
+ };
5989
+ new ResizeObserver(report).observe(wrapper);
5990
+ // The parent asks for a fresh report when its listener comes up, in
5991
+ // case the first one above was posted before anyone was listening.
5992
+ window.addEventListener("message", (event) => {
5993
+ if (
5994
+ event.source === window.parent &&
5995
+ event.origin === window.location.origin &&
5996
+ event.data?.type === "blume:example-height-request"
5997
+ ) {
5998
+ report();
5999
+ }
6000
+ });
5969
6001
  })();
5970
6002
  </script>
5971
6003
  </body>
@@ -6341,7 +6373,7 @@ var pathOnly = (value) => {
6341
6373
  const cut = value.search(/[?#]/u);
6342
6374
  return cut === -1 ? value : value.slice(0, cut);
6343
6375
  };
6344
- var resolveRedirects = (redirects, pageUrls) => {
6376
+ var resolveRedirects = (redirects, served) => {
6345
6377
  const byFrom = new Map;
6346
6378
  for (const redirect of redirects) {
6347
6379
  byFrom.set(normalizePath(redirect.from), redirect);
@@ -6375,7 +6407,7 @@ var resolveRedirects = (redirects, pageUrls) => {
6375
6407
  }
6376
6408
  const destination = chain.at(-1) ?? from;
6377
6409
  const external = /^https?:\/\//iu.test(destination);
6378
- if (!(external || pageUrls.has(destination))) {
6410
+ if (!(external || served(destination))) {
6379
6411
  return { ...redirect, chain, outcome: "broken" };
6380
6412
  }
6381
6413
  return {
@@ -6463,7 +6495,7 @@ var runAudit = async (options) => {
6463
6495
  ...redirect,
6464
6496
  from: withBasePath(basePath, redirect.from),
6465
6497
  to: withBasePath(basePath, redirect.to)
6466
- })), new Set([...byUrl.keys(), ...crawl.files.keys()].map((path) => normalizePath(path)))),
6498
+ })), (path) => isServed({ byUrl, files: crawl.files, project }, path)),
6467
6499
  robots: crawl.robots,
6468
6500
  sitemap: crawl.sitemap,
6469
6501
  sources: await readSources(crawl.pages),
@@ -10876,6 +10908,9 @@ var analyticsScriptSchema = z2.strictObject({
10876
10908
  message: "An analytics script must set exactly one of `src` or `content`."
10877
10909
  });
10878
10910
  var analyticsConfigSchema = z2.strictObject({
10911
+ cloudflare: z2.strictObject({
10912
+ token: z2.string().min(1)
10913
+ }).optional(),
10879
10914
  posthog: z2.strictObject({
10880
10915
  host: z2.string().optional(),
10881
10916
  key: z2.string()
@@ -12386,13 +12421,20 @@ var toHeading = (depth, raw, slugger, isRefDefined) => {
12386
12421
  const markers = parseHeadingMarkers(unescaped, isRefDefined);
12387
12422
  const text = markers.text.trim();
12388
12423
  if (text === "" && (markers.id !== undefined || markers.toc !== undefined)) {
12389
- return { depth, slug: slugger.slug(unescaped), text: unescaped };
12424
+ return {
12425
+ heading: { depth, slug: slugger.slug(unescaped), text: unescaped },
12426
+ pinned: false
12427
+ };
12390
12428
  }
12391
12429
  if (markers.id !== undefined) {
12392
12430
  occupySlug(slugger, markers.id);
12393
- return { depth, slug: markers.id, text };
12431
+ return { heading: { depth, slug: markers.id, text }, pinned: true };
12394
12432
  }
12395
- return { depth, slug: slugger.slug(text), text };
12433
+ return { heading: { depth, slug: slugger.slug(text), text }, pinned: false };
12434
+ };
12435
+ var pushHeading = (headings, state, scanned, line) => {
12436
+ headings.push(scanned.heading);
12437
+ state.sites.push({ line, pinned: scanned.pinned });
12396
12438
  };
12397
12439
  var noteCurlyMarker = (text, line, state) => {
12398
12440
  const id2 = text.match(BARE_CURLY_MARKER)?.groups?.id;
@@ -12406,7 +12448,7 @@ var scanContentLine = (line, state, slugger, headings, isRefDefined) => {
12406
12448
  if (atx?.groups) {
12407
12449
  const depth = atx.groups.hashes?.length ?? 1;
12408
12450
  const text = (atx.groups.text ?? "").trim();
12409
- headings.push(toHeading(depth, text, slugger, isRefDefined));
12451
+ pushHeading(headings, state, toHeading(depth, text, slugger, isRefDefined), state.line);
12410
12452
  noteCurlyMarker(text, state.line, state);
12411
12453
  state.paragraph = [];
12412
12454
  return;
@@ -12415,7 +12457,7 @@ var scanContentLine = (line, state, slugger, headings, isRefDefined) => {
12415
12457
  if (setext?.groups && state.paragraph.length > 0) {
12416
12458
  const depth = setext.groups.marker?.startsWith("=") ? 1 : 2;
12417
12459
  const text = state.paragraph.join(" ").trim();
12418
- headings.push(toHeading(depth, text, slugger, isRefDefined));
12460
+ pushHeading(headings, state, toHeading(depth, text, slugger, isRefDefined), state.line - 1);
12419
12461
  noteCurlyMarker(text, state.paragraphStart, state);
12420
12462
  state.paragraph = [];
12421
12463
  return;
@@ -12467,7 +12509,8 @@ var scanBody = (body) => {
12467
12509
  paragraph: [],
12468
12510
  paragraphStart: 0,
12469
12511
  promptDepth: 0,
12470
- promptTag: false
12512
+ promptTag: false,
12513
+ sites: []
12471
12514
  };
12472
12515
  const { lines, offset } = linesWithoutFrontMatter(body);
12473
12516
  const definedLabels = refDefinitionLabels(lines);
@@ -12485,7 +12528,12 @@ var scanBody = (body) => {
12485
12528
  anchors.add(id2);
12486
12529
  }
12487
12530
  }
12488
- return { anchors: [...anchors], curlyMarkers: state.curlyMarkers, headings };
12531
+ return {
12532
+ anchors: [...anchors],
12533
+ curlyMarkers: state.curlyMarkers,
12534
+ headings,
12535
+ sites: state.sites
12536
+ };
12489
12537
  };
12490
12538
  var extractHeadings = (body) => scanBody(body).headings;
12491
12539
  var MD_LINK = /\[(?<label>(?:[^[\]]|\[[^\]]*\])*)\]\((?<target>(?:[^()\s]|\([^()\s]*\))+)(?<title>\s+"[^"]*")?\)/gu;
@@ -13415,6 +13463,33 @@ var operationKey = (method, path, operationId) => {
13415
13463
  const fromId = operationId ? slugify(splitIdentifier(operationId)) : "";
13416
13464
  return fromId || slugify(`${method}-${path}`);
13417
13465
  };
13466
+ var specOf = (specs, source) => Object.hasOwn(specs, source) ? specs[source] : undefined;
13467
+ var operationOf = (spec, id2) => Object.hasOwn(spec.operations, id2) ? spec.operations[id2] : undefined;
13468
+ var specAddresses = (spec) => {
13469
+ const addresses = [];
13470
+ if (spec.kind === "graphql") {
13471
+ if (spec.endpoint) {
13472
+ addresses.push(spec.endpoint);
13473
+ }
13474
+ return { addresses, label: "Endpoint" };
13475
+ }
13476
+ if (spec.kind === "asyncapi") {
13477
+ const servers = spec.document.servers ?? {};
13478
+ for (const server of Object.values(servers)) {
13479
+ if (server?.host) {
13480
+ addresses.push(`${server.protocol ? `${server.protocol}://` : ""}${server.host}${server.pathname ?? ""}`);
13481
+ }
13482
+ }
13483
+ return { addresses, label: "Servers" };
13484
+ }
13485
+ const declared = spec.document.servers;
13486
+ for (const server of Array.isArray(declared) ? declared : []) {
13487
+ if (server.url) {
13488
+ addresses.push(server.url);
13489
+ }
13490
+ }
13491
+ return { addresses, label: "Base URL" };
13492
+ };
13418
13493
  var isOperation = (value) => typeof value === "object" && value !== null;
13419
13494
  var hasTagName = (tag) => typeof tag.name === "string";
13420
13495
  var tagSlugger = () => {
@@ -13673,6 +13748,19 @@ var GRAPHQL_GROUP_LABELS = {
13673
13748
  union: "Unions"
13674
13749
  };
13675
13750
  var isGraphqlOperationKind = (method) => GRAPHQL_OPERATION_KINDS.some((kind) => kind === method);
13751
+ var GRAPHQL_TYPE_KEYWORDS = {
13752
+ enum: "enum",
13753
+ input: "input",
13754
+ interface: "interface",
13755
+ object: "type",
13756
+ scalar: "scalar",
13757
+ union: "union"
13758
+ };
13759
+ var graphqlSignature = (operation) => {
13760
+ const member = operation.method;
13761
+ const keyword = isGraphqlOperationKind(member) ? member : GRAPHQL_TYPE_KEYWORDS[member];
13762
+ return `${keyword} ${operation.path}`;
13763
+ };
13676
13764
  var byName = (a, b) => a.name < b.name ? -1 : 1;
13677
13765
  var extractGraphqlOperations = (document, baseRoute) => {
13678
13766
  const collector = operationCollector(baseRoute, new Map);
@@ -14115,6 +14203,9 @@ var columnsPrefix = (text, max) => {
14115
14203
  return text.slice(0, end);
14116
14204
  };
14117
14205
 
14206
+ // src/openapi/signature.ts
14207
+ var operationSignature = (spec, operation) => spec.kind === "graphql" ? graphqlSignature(operation) : `${operation.method.toUpperCase()} ${operation.path}`;
14208
+
14118
14209
  // src/openapi/render-mdx.ts
14119
14210
  var MDX_UNSAFE = /[<{}]/gu;
14120
14211
  var ENTITIES = new Map([
@@ -14207,7 +14298,7 @@ ${component}` : component;
14207
14298
  var operationMdx = (spec, operation, reference) => {
14208
14299
  const method = operation.method.toUpperCase();
14209
14300
  const graphql = spec.kind === "graphql";
14210
- const fallbackTitle = graphql ? operation.path : `${method} ${operation.path}`;
14301
+ const fallbackTitle = graphql ? operation.path : operationSignature(spec, operation);
14211
14302
  const title = operation.summary || fallbackTitle;
14212
14303
  const description = operation.description.trim() === operation.summary.trim() ? "" : operation.description;
14213
14304
  const flags = {};
@@ -16989,6 +17080,13 @@ var youtube = ({ props }) => {
16989
17080
  const title = isString4(props.title) && props.title !== "" ? props.title : "Watch on YouTube";
16990
17081
  return `[${title}](https://www.youtube.com/watch?v=${videoId}${start})`;
16991
17082
  };
17083
+ var inlineCode = (text) => {
17084
+ const runs = text.match(/`+/gu);
17085
+ const longest = runs ? Math.max(...runs.map((run) => run.length)) : 0;
17086
+ const delimiter = "`".repeat(longest + 1);
17087
+ const padded = text.startsWith("`") || text.endsWith("`") ? ` ${text} ` : text;
17088
+ return `${delimiter}${padded}${delimiter}`;
17089
+ };
16992
17090
  var fencedBlock = (lang, code) => {
16993
17091
  const trimmed = code.replace(/(?<!\n)\n+$/u, "");
16994
17092
  const runs = trimmed.match(/`+/gu);
@@ -17090,6 +17188,67 @@ var downlevelComponents = (source, components, frontmatter) => {
17090
17188
  return splices.length > 0 ? applySplices(source, splices) : source;
17091
17189
  };
17092
17190
 
17191
+ // src/ai/openapi-components.ts
17192
+ var inlineText = (text) => text.trim().replaceAll(/\s+/gu, " ").replaceAll(/[\\`*_[\]<>~]/gu, String.raw`\$&`);
17193
+ var listItem2 = (signature, operation) => {
17194
+ const tail = [
17195
+ inlineText(operation.summary),
17196
+ operation.deprecated ? "Deprecated." : ""
17197
+ ].filter(Boolean).join(" ");
17198
+ return `- [${inlineCode(signature)}](${linkDestination(operation.route)})${tail ? ` — ${tail}` : ""}`;
17199
+ };
17200
+ var openapiComponentSerializers = (specs) => {
17201
+ const spec = (source) => isString4(source) ? specOf(specs, source) : undefined;
17202
+ return {
17203
+ ApiOverview: ({ props }) => {
17204
+ const data = spec(props.source);
17205
+ if (!data) {
17206
+ return null;
17207
+ }
17208
+ const { addresses, label } = specAddresses(data);
17209
+ const lines = [
17210
+ data.version ? `Version ${inlineText(data.version)}` : "",
17211
+ addresses.length > 0 ? `${label}: ${addresses.map(inlineCode).join(", ")}` : ""
17212
+ ].filter(Boolean);
17213
+ return lines.length > 0 ? lines.join(`
17214
+
17215
+ `) : null;
17216
+ },
17217
+ ApiTagOperations: ({ props }) => {
17218
+ const { tag } = props;
17219
+ const data = spec(props.source);
17220
+ if (!(data && isString4(tag))) {
17221
+ return null;
17222
+ }
17223
+ const items = Object.values(data.operations).filter((operation) => operation.tagSlug === tag).map((operation) => listItem2(operationSignature(data, operation), operation));
17224
+ return items.length > 0 ? items.join(`
17225
+ `) : null;
17226
+ },
17227
+ Operation: ({ props }) => {
17228
+ const { id: id2 } = props;
17229
+ const data = spec(props.source);
17230
+ if (!(data && isString4(id2))) {
17231
+ return null;
17232
+ }
17233
+ const operation = operationOf(data, id2);
17234
+ if (!operation) {
17235
+ return null;
17236
+ }
17237
+ const signature = inlineCode(operationSignature(data, operation));
17238
+ return operation.deprecated ? `${signature}
17239
+
17240
+ **Deprecated.**` : signature;
17241
+ }
17242
+ };
17243
+ };
17244
+
17245
+ // src/ai/serializers.ts
17246
+ var projectComponentSerializers = (project) => ({
17247
+ ...exampleComponentSerializers(project.examples ?? {}),
17248
+ ...openapiComponentSerializers(project.sources.find(isOpenApiSource)?.openApiData() ?? {}),
17249
+ ...project.config.ai.markdownComponents
17250
+ });
17251
+
17093
17252
  // src/ai/skills.ts
17094
17253
  import { createHash as createHash3 } from "node:crypto";
17095
17254
  import { readdir as readdir2, readFile as readFile12, stat as stat3 } from "node:fs/promises";
@@ -17405,10 +17564,7 @@ ${details}` : header;
17405
17564
  var buildFull = async (project) => {
17406
17565
  const { config } = project;
17407
17566
  const pages = eligiblePages(project, { versions: "current" }).toSorted((a, b) => a.route.localeCompare(b.route));
17408
- const components = {
17409
- ...exampleComponentSerializers(project.examples ?? {}),
17410
- ...config.ai.markdownComponents
17411
- };
17567
+ const components = projectComponentSerializers(project);
17412
17568
  const sections = await Promise.all(pages.map(async (page) => {
17413
17569
  let raw = await readExpandedEntryText(project, page);
17414
17570
  if (page.sourcePath) {
@@ -17449,10 +17605,7 @@ var agentMarkdown = (entry) => entry.md ?? entry.mdx;
17449
17605
  var markdownTokenCount = (text) => Math.ceil(text.length / 4);
17450
17606
  var buildRawMarkdown = async (project) => {
17451
17607
  const pageById = new Map(project.graph.pages.map((page) => [page.id, page]));
17452
- const components = {
17453
- ...exampleComponentSerializers(project.examples ?? {}),
17454
- ...project.config.ai.markdownComponents
17455
- };
17608
+ const components = projectComponentSerializers(project);
17456
17609
  const readRoute = async (route) => {
17457
17610
  const page = pageById.get(route.id);
17458
17611
  if (page) {
@@ -18594,10 +18747,7 @@ var buildSearchDocuments = async (project, options) => {
18594
18747
  const page = pageById.get(route.id);
18595
18748
  return page ? contentIndexable(page, project.config) : false;
18596
18749
  });
18597
- const components = {
18598
- ...exampleComponentSerializers(project.examples ?? {}),
18599
- ...project.config.ai.markdownComponents
18600
- };
18750
+ const components = projectComponentSerializers(project);
18601
18751
  return await Promise.all(indexable.map(async (route) => {
18602
18752
  const page = pageById.get(route.id);
18603
18753
  const body = await pageBody(project, page, options, components);
@@ -20290,6 +20440,7 @@ var resolveSearchPopular = (popular, basePath) => popular.map(({ href, icon, lab
20290
20440
  var CODE_PADDING_BLOCK_REM = 1;
20291
20441
 
20292
20442
  // src/theme/entry.ts
20443
+ var CODE_SCROLL_INSET_REM = 0.375;
20293
20444
  var DARK_VARIANT = `/* Dark mode is driven by data-theme on the <html> element. */
20294
20445
  @custom-variant dark (&:where([data-theme="dark"], [data-theme="dark"] *));`;
20295
20446
  var COLOR_SCHEME_DEFAULTS = `:root {
@@ -20747,8 +20898,9 @@ blume-diff {
20747
20898
  max-height: 24rem;
20748
20899
  overflow: auto;
20749
20900
  /* The small bottom inset keeps the horizontal thumb off the last line's
20750
- descenders now that scrollbars are visible. */
20751
- padding: 0 1.25rem 0.375rem;
20901
+ descenders now that scrollbars are visible. The pre gives up the same
20902
+ amount below (next rule), so the inset adds no height to the block. */
20903
+ padding: 0 1.25rem ${CODE_SCROLL_INSET_REM}rem;
20752
20904
  /* Thin theme-colored scrollbars, matching the sidebar treatment, so a
20753
20905
  height-capped block reads as scrollable instead of simply ending.
20754
20906
  Safari before 18.2 supports neither property and falls back to the
@@ -20757,6 +20909,14 @@ blume-diff {
20757
20909
  scrollbar-width: thin;
20758
20910
  }
20759
20911
 
20912
+ /* The scroller's bottom inset comes out of the pre's own block padding: the
20913
+ text still sits one full inset above the frame's bottom edge, the thumb sits
20914
+ in the gap, and a one-line command is no taller than it was before the
20915
+ scroller existed. */
20916
+ .prose :where(pre:not(.twoslash, .twoslash pre, blume-panel-tabs *):has(> code)) {
20917
+ padding-bottom: calc(${CODE_PADDING_BLOCK_REM}rem - ${CODE_SCROLL_INSET_REM}rem);
20918
+ }
20919
+
20760
20920
  /* The dark border token is too close to the page background to read as a
20761
20921
  scrollbar thumb; derive a brighter one from the muted foreground instead. */
20762
20922
  :root[data-theme="dark"]
@@ -20795,9 +20955,16 @@ blume-diff {
20795
20955
  /* Restore inner padding on every cell. Typography zeroes the first/last cell's
20796
20956
  inline padding so a borderless table aligns to the prose margin; inside the
20797
20957
  framed wrapper that leaves edge text touching the border. The :is() selector
20798
- outweighs Typography's :where()-scoped rules so the outer columns get it too. */
20958
+ outweighs Typography's :where()-scoped rules so the outer columns get it too.
20959
+
20960
+ The block padding is 0.75rem against a table line-height near 1.7: at 0.5rem a
20961
+ cell whose content wrapped put MORE space between its own two lines than
20962
+ between itself and the next row, so a table of wrapping cells read as one
20963
+ block rather than as rows. The inline padding stays where it was, deliberately
20964
+ — widening it comes out of column width in a capped article, and on one corpus
20965
+ that pushed cells fitting on two lines onto three. */
20799
20966
  .blume-table-scroll :is(th, td) {
20800
- padding: 0.5rem 0.75rem;
20967
+ padding: 0.75rem;
20801
20968
  }
20802
20969
  /* Keep column labels on one line so a two-word header does not wrap into a
20803
20970
  ragged stack; the table just scrolls a little wider instead. Body cells keep
@@ -21610,9 +21777,9 @@ var islandFrameworkWarnings = (frameworks, root) => {
21610
21777
  }
21611
21778
  return warnings;
21612
21779
  };
21613
- var deploymentAdapterWarnings = (deployment, root) => {
21780
+ var deploymentAdapterWarnings = (deployment, root, pkgDir = packageRoot()) => {
21614
21781
  const dep = deployment.output === "server" && deployment.adapter ? DEPLOYMENT_ADAPTER_DEPS.get(deployment.adapter) : undefined;
21615
- if (dep && !(canResolveFrom(root, dep) || canResolveFrom(packageRoot(), dep))) {
21782
+ if (dep && !(canResolveFrom(root, dep) || canResolveFrom(pkgDir, dep))) {
21616
21783
  return [
21617
21784
  `Deployment adapter "${deployment.adapter}" needs "${dep}", which isn't installed. Run \`npm install ${dep}\` (or your package manager's equivalent).`
21618
21785
  ];
@@ -26151,6 +26318,57 @@ Write the titles in this style: ${target.style}`}
26151
26318
 
26152
26319
  ${JSON.stringify(titles, null, 2)}`;
26153
26320
 
26321
+ // src/translate/anchors.ts
26322
+ var ATX_CLOSE = /\s+#+$/u;
26323
+ var structureOf = (headings) => headings.map((heading) => heading.depth).join(",");
26324
+ var pinLine = (line, id2) => {
26325
+ const eol = line.endsWith("\r") ? "\r" : "";
26326
+ const body = line.slice(0, line.length - eol.length).trimEnd();
26327
+ const close = body.match(ATX_CLOSE)?.[0] ?? "";
26328
+ const head = body.slice(0, body.length - close.length);
26329
+ return `${head} [#${id2}]${close}${eol}`;
26330
+ };
26331
+ var pinHeadingAnchors = (sourceText, translatedText) => {
26332
+ const source = scanBody(sourceText);
26333
+ const translated = scanBody(translatedText);
26334
+ if (structureOf(source.headings) !== structureOf(translated.headings)) {
26335
+ return {
26336
+ pinned: 0,
26337
+ skipped: `heading structure differs (source has ${source.headings.length} headings, translation has ${translated.headings.length})`,
26338
+ text: translatedText
26339
+ };
26340
+ }
26341
+ const lines = translatedText.split(`
26342
+ `);
26343
+ let pinned = 0;
26344
+ for (const [index, heading] of translated.headings.entries()) {
26345
+ const site = translated.sites[index];
26346
+ const sourceId = source.headings[index]?.slug;
26347
+ if (!site || site.pinned || sourceId === undefined || heading.slug === sourceId) {
26348
+ continue;
26349
+ }
26350
+ lines[site.line - 1] = pinLine(lines[site.line - 1] ?? "", sourceId);
26351
+ pinned += 1;
26352
+ }
26353
+ if (pinned === 0) {
26354
+ return { pinned, text: translatedText };
26355
+ }
26356
+ const text2 = lines.join(`
26357
+ `);
26358
+ const rendered = scanBody(text2).headings.map((heading) => heading.slug);
26359
+ const expected = source.headings.map((heading) => heading.slug);
26360
+ if (rendered.join(`
26361
+ `) !== expected.join(`
26362
+ `)) {
26363
+ return {
26364
+ pinned: 0,
26365
+ skipped: "pinned anchors did not reproduce the source heading ids",
26366
+ text: translatedText
26367
+ };
26368
+ }
26369
+ return { pinned, text: text2 };
26370
+ };
26371
+
26154
26372
  // src/translate/validate.ts
26155
26373
  var FRONTMATTER_OPEN = /^---\r?\n/u;
26156
26374
  var FENCE_LINE = /^\s*(?:```|~~~)/u;
@@ -26202,18 +26420,19 @@ var validateTranslation = (sourceText, agentText) => {
26202
26420
  } catch {
26203
26421
  return { ok: false, reason: "frontmatter does not parse as YAML" };
26204
26422
  }
26205
- const body = ensureTrailingNewline(parsed.content.replace(/^\r?\n/u, ""));
26206
- if (body.trim() === "") {
26423
+ const rawBody = ensureTrailingNewline(parsed.content.replace(/^\r?\n/u, ""));
26424
+ if (rawBody.trim() === "") {
26207
26425
  return { ok: false, reason: "translation has an empty body" };
26208
26426
  }
26209
26427
  const sourceFences = countFenceLines(source.content);
26210
- const candidateFences = countFenceLines(body);
26428
+ const candidateFences = countFenceLines(rawBody);
26211
26429
  if (sourceFences !== candidateFences) {
26212
26430
  return {
26213
26431
  ok: false,
26214
26432
  reason: `code fence count changed (source has ${sourceFences}, translation has ${candidateFences})`
26215
26433
  };
26216
26434
  }
26435
+ const body = pinHeadingAnchors(source.content, rawBody).text;
26217
26436
  if (!sourceHasFrontmatter) {
26218
26437
  return { ok: true, text: body };
26219
26438
  }
@@ -26784,10 +27003,38 @@ import { join as join50 } from "pathe";
26784
27003
  // src/core/links.ts
26785
27004
  import { existsSync as existsSync27 } from "node:fs";
26786
27005
  import { basename as basename8, dirname as dirname20, join as join49, relative as relative25, resolve as resolve16 } from "pathe";
27006
+
27007
+ // src/core/locale-links.ts
27008
+ var decodePercent = (value) => {
27009
+ try {
27010
+ return decodeURIComponent(value);
27011
+ } catch {
27012
+ return value;
27013
+ }
27014
+ };
27015
+ var hasLocalePrefix = (path, i18n) => i18n.locales.some((locale) => {
27016
+ const prefix = localePrefix(locale.code, i18n);
27017
+ return prefix !== "" && (path === prefix || path.startsWith(`${prefix}/`));
27018
+ });
27019
+ var localizeLinkPath = (path, options) => {
27020
+ const { basePath, i18n, locale, routes } = options;
27021
+ if (localePrefix(locale, i18n) === "") {
27022
+ return path;
27023
+ }
27024
+ const rest = normalizePath(stripBasePath(basePath, path));
27025
+ if (hasLocalePrefix(rest, i18n)) {
27026
+ return path;
27027
+ }
27028
+ const localized = withBasePath(basePath, localizeRoute(rest, locale, i18n));
27029
+ return routes.has(localized) || routes.has(decodePercent(localized)) ? localized : path;
27030
+ };
27031
+ var routeSets = new WeakMap;
27032
+
27033
+ // src/core/links.ts
26787
27034
  var HTTP = /^https?:\/\//iu;
26788
27035
  var PROTOCOL_RELATIVE = /^\/\//u;
26789
27036
  var SCHEME = /^[a-z][a-z0-9+.-]*:/iu;
26790
- var decodePercent = (value) => {
27037
+ var decodePercent2 = (value) => {
26791
27038
  try {
26792
27039
  return decodeURIComponent(value);
26793
27040
  } catch {
@@ -26856,8 +27103,17 @@ var checkAnchor = (route, fragment, site, ctx, via = "") => {
26856
27103
  severity: "warning"
26857
27104
  };
26858
27105
  };
27106
+ var servedRoute = (authored, page2, ctx) => ctx.i18n ? localizeLinkPath(authored, {
27107
+ basePath: ctx.basePath,
27108
+ i18n: ctx.i18n,
27109
+ locale: page2.locale,
27110
+ routes: {
27111
+ has: (route) => ctx.routes.has(route) || ctx.extraRoutes.has(route)
27112
+ }
27113
+ }) : authored;
26859
27114
  var checkPathLink = (resolved, fragment, page2, link, site, ctx, via = "") => {
26860
- const route = toRoute(withBasePath(ctx.basePath, resolved));
27115
+ const authoredRoute = toRoute(withBasePath(ctx.basePath, resolved));
27116
+ const route = servedRoute(authoredRoute, page2, ctx);
26861
27117
  if (ctx.routes.has(route)) {
26862
27118
  return fragment ? checkAnchor(route, fragment, site, ctx, via) : null;
26863
27119
  }
@@ -26941,13 +27197,13 @@ var classifyLink = (page2, link, ctx, onExternal) => {
26941
27197
  return null;
26942
27198
  }
26943
27199
  const hashIndex = target.indexOf("#");
26944
- const fragment = decodePercent(hashIndex === -1 ? "" : target.slice(hashIndex + 1));
27200
+ const fragment = decodePercent2(hashIndex === -1 ? "" : target.slice(hashIndex + 1));
26945
27201
  let rawPath = hashIndex === -1 ? target : target.slice(0, hashIndex);
26946
27202
  const queryIndex = rawPath.indexOf("?");
26947
27203
  if (queryIndex !== -1) {
26948
27204
  rawPath = rawPath.slice(0, queryIndex);
26949
27205
  }
26950
- rawPath = decodePercent(rawPath);
27206
+ rawPath = decodePercent2(rawPath);
26951
27207
  const via = rawPath.startsWith("/") ? "" : includedBySuffix(link, page2);
26952
27208
  if (rawPath === "") {
26953
27209
  return fragment ? checkAnchor(page2.route, fragment, site, ctx, via) : null;
@@ -26961,6 +27217,7 @@ var validateLinks = async (graph, options) => {
26961
27217
  anchors: buildAnchorIndex(graph.pages),
26962
27218
  basePath,
26963
27219
  extraRoutes: new Set((options.extraRoutes ?? []).map(toRoute)),
27220
+ i18n: options.i18n ?? null,
26964
27221
  publicDir: options.publicDir,
26965
27222
  redirects: new Set((options.redirects ?? []).map((redirect) => toRoute(withBasePath(basePath, redirect.from)))),
26966
27223
  routes: new Set(graph.routes.keys())
@@ -27050,6 +27307,7 @@ var validateCommand = defineCommand14({
27050
27307
  basePath: project.config.basePath,
27051
27308
  checkExternal: Boolean(args.external),
27052
27309
  extraRoutes,
27310
+ i18n: project.config.i18n,
27053
27311
  publicDir: existsSync28(publicDir) ? publicDir : null,
27054
27312
  redirects: project.config.redirects
27055
27313
  }));
@@ -27368,5 +27626,5 @@ process.on("unhandledRejection", (error) => {
27368
27626
  });
27369
27627
  runMain(main, { rawArgs: normalizeHostArgs(process.argv.slice(2)) });
27370
27628
 
27371
- //# debugId=91C1BFDA6463CA2664756E2164756E21
27629
+ //# debugId=AF304483DD33488E64756E2164756E21
27372
27630
  //# sourceMappingURL=index.js.map