reroute-js 1.0.0-alpha.6 → 1.0.0-alpha.8

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 (207) hide show
  1. package/README.md +5 -3
  2. package/cli/bin.d.ts +1 -1
  3. package/cli/bin.js +149 -46
  4. package/cli/bin.js.map +9 -9
  5. package/cli/index.d.ts +1 -1
  6. package/cli/index.js +4 -4
  7. package/cli/index.js.map +1 -1
  8. package/cli/src/cli.d.ts +1 -1
  9. package/cli/src/commands/analyze.d.ts +1 -1
  10. package/cli/src/commands/build.d.ts +1 -1
  11. package/cli/src/commands/dev.d.ts +1 -1
  12. package/cli/src/commands/gen.d.ts +1 -1
  13. package/cli/src/commands/index.d.ts +1 -1
  14. package/cli/src/commands/init.d.ts +1 -1
  15. package/cli/src/commands/lib/assets.d.ts +1 -1
  16. package/cli/src/commands/lib/bundler.d.ts +1 -1
  17. package/cli/src/commands/lib/command.d.ts +1 -1
  18. package/cli/src/commands/lib/env.d.ts +1 -1
  19. package/cli/src/commands/lib/index.d.ts +1 -1
  20. package/cli/src/commands/lib/log.d.ts +1 -1
  21. package/cli/src/commands/lib/markdown/availability.d.ts +1 -1
  22. package/cli/src/commands/lib/markdown/index.d.ts +1 -1
  23. package/cli/src/commands/lib/markdown/processor.d.ts +1 -1
  24. package/cli/src/commands/lib/production.d.ts +1 -1
  25. package/cli/src/commands/lib/server.d.ts +1 -1
  26. package/cli/src/commands/lib/streaming/analyzer.d.ts +1 -1
  27. package/cli/src/commands/lib/streaming/suspense.d.ts +1 -1
  28. package/cli/src/commands/lib/terminal-ui.d.ts +1 -1
  29. package/cli/src/commands/lib/theme.d.ts +1 -1
  30. package/cli/src/commands/lib/version.d.ts +1 -1
  31. package/cli/src/commands/og.d.ts +1 -1
  32. package/cli/src/commands/start.d.ts +1 -1
  33. package/cli/src/index.d.ts +1 -1
  34. package/core/index.d.ts +1 -1
  35. package/core/index.js +145 -42
  36. package/core/index.js.map +9 -9
  37. package/core/src/bundler/hash.d.ts +1 -1
  38. package/core/src/bundler/index.d.ts +1 -1
  39. package/core/src/config.d.ts +7 -1
  40. package/core/src/config.d.ts.map +1 -1
  41. package/core/src/content/discovery.d.ts +1 -1
  42. package/core/src/content/index.d.ts +1 -1
  43. package/core/src/content/metadata.d.ts +1 -1
  44. package/core/src/i18n/catalog.d.ts +1 -1
  45. package/core/src/i18n/discover.d.ts +1 -1
  46. package/core/src/i18n/index.d.ts +1 -1
  47. package/core/src/i18n/messages.d.ts +1 -1
  48. package/core/src/i18n/negotiate.d.ts +1 -1
  49. package/core/src/i18n/pathname.d.ts +1 -1
  50. package/core/src/i18n/resolve.d.ts +4 -3
  51. package/core/src/i18n/resolve.d.ts.map +1 -1
  52. package/core/src/i18n/types.d.ts +5 -1
  53. package/core/src/i18n/types.d.ts.map +1 -1
  54. package/core/src/index.d.ts +1 -1
  55. package/core/src/llms/extractor.d.ts +1 -1
  56. package/core/src/llms/formatter.d.ts +1 -1
  57. package/core/src/llms/full-generator.d.ts +1 -1
  58. package/core/src/llms/index-generator.d.ts +3 -2
  59. package/core/src/llms/index-generator.d.ts.map +1 -1
  60. package/core/src/llms/index.d.ts +1 -1
  61. package/core/src/og/discovery.d.ts +1 -1
  62. package/core/src/og/index.d.ts +1 -1
  63. package/core/src/og/meta.d.ts +1 -1
  64. package/core/src/og/render.d.ts +1 -1
  65. package/core/src/og/types.d.ts +1 -1
  66. package/core/src/robots/discovery.d.ts +1 -1
  67. package/core/src/robots/generator.d.ts +1 -1
  68. package/core/src/robots/index.d.ts +1 -1
  69. package/core/src/robots/policies.d.ts +1 -1
  70. package/core/src/rss/discovery.d.ts +1 -1
  71. package/core/src/rss/generator.d.ts +1 -1
  72. package/core/src/rss/index.d.ts +1 -1
  73. package/core/src/sitemap/discovery.d.ts +1 -1
  74. package/core/src/sitemap/generator.d.ts +1 -1
  75. package/core/src/sitemap/index.d.ts +1 -1
  76. package/core/src/ssr/index.d.ts +1 -1
  77. package/core/src/ssr/lib/cache.d.ts +1 -1
  78. package/core/src/ssr/lib/cleanup.d.ts +1 -1
  79. package/core/src/ssr/lib/collections.d.ts +17 -1
  80. package/core/src/ssr/lib/collections.d.ts.map +1 -1
  81. package/core/src/ssr/lib/compression.d.ts +1 -1
  82. package/core/src/ssr/lib/compute/content.d.ts +1 -1
  83. package/core/src/ssr/lib/compute/index.d.ts +1 -1
  84. package/core/src/ssr/lib/compute/layouts.d.ts +1 -1
  85. package/core/src/ssr/lib/compute/routes.d.ts +1 -1
  86. package/core/src/ssr/lib/content-path.d.ts +1 -1
  87. package/core/src/ssr/lib/data.d.ts +1 -1
  88. package/core/src/ssr/lib/html.d.ts +1 -1
  89. package/core/src/ssr/lib/imports.d.ts +1 -1
  90. package/core/src/ssr/lib/index.d.ts +1 -1
  91. package/core/src/ssr/lib/layouts.d.ts +1 -1
  92. package/core/src/ssr/lib/metadata.d.ts +1 -1
  93. package/core/src/ssr/lib/mime.d.ts +1 -1
  94. package/core/src/ssr/lib/modules.d.ts +1 -1
  95. package/core/src/ssr/lib/path.d.ts +1 -1
  96. package/core/src/ssr/lib/preload.d.ts +1 -1
  97. package/core/src/ssr/lib/route-match.d.ts +1 -1
  98. package/core/src/ssr/lib/scripts/collections.d.ts +2 -2
  99. package/core/src/ssr/lib/scripts/collections.d.ts.map +1 -1
  100. package/core/src/ssr/lib/scripts/data.d.ts +1 -1
  101. package/core/src/ssr/lib/scripts/escape.d.ts +1 -1
  102. package/core/src/ssr/lib/scripts/feeds.d.ts +1 -1
  103. package/core/src/ssr/lib/scripts/index.d.ts +1 -1
  104. package/core/src/ssr/lib/seed.d.ts +1 -1
  105. package/core/src/ssr/lib/serialize.d.ts +1 -1
  106. package/core/src/ssr/lib/setup.d.ts +2 -2
  107. package/core/src/ssr/lib/setup.d.ts.map +1 -1
  108. package/core/src/ssr/lib/styles.d.ts +1 -1
  109. package/core/src/ssr/lib/template.d.ts +1 -1
  110. package/core/src/ssr/lib/types.d.ts +1 -1
  111. package/core/src/ssr/render.d.ts +1 -1
  112. package/core/src/ssr/render.d.ts.map +1 -1
  113. package/core/src/ssr/stream.d.ts +1 -1
  114. package/elysia/index.d.ts +1 -1
  115. package/elysia/index.js +152 -47
  116. package/elysia/index.js.map +11 -11
  117. package/elysia/src/index.d.ts +1 -1
  118. package/elysia/src/libs/assets.d.ts +1 -1
  119. package/elysia/src/libs/cache.d.ts +1 -1
  120. package/elysia/src/libs/caching.d.ts +1 -1
  121. package/elysia/src/libs/http.d.ts +1 -1
  122. package/elysia/src/libs/i18n.d.ts +2 -2
  123. package/elysia/src/libs/i18n.d.ts.map +1 -1
  124. package/elysia/src/libs/image.d.ts +1 -1
  125. package/elysia/src/libs/index.d.ts +1 -1
  126. package/elysia/src/libs/llms.d.ts +1 -1
  127. package/elysia/src/libs/response.d.ts +1 -1
  128. package/elysia/src/libs/serving.d.ts +1 -1
  129. package/elysia/src/plugin.d.ts +1 -1
  130. package/elysia/src/routes/artifacts.d.ts +1 -1
  131. package/elysia/src/routes/content.d.ts +1 -1
  132. package/elysia/src/routes/image.d.ts +1 -1
  133. package/elysia/src/routes/index.d.ts +1 -1
  134. package/elysia/src/routes/internal.d.ts +1 -1
  135. package/elysia/src/routes/llms.d.ts +1 -1
  136. package/elysia/src/routes/og.d.ts +1 -1
  137. package/elysia/src/routes/redirects.d.ts +1 -1
  138. package/elysia/src/routes/robots.d.ts +1 -1
  139. package/elysia/src/routes/rss.d.ts +1 -1
  140. package/elysia/src/routes/search.d.ts +1 -1
  141. package/elysia/src/routes/sitemap.d.ts +1 -1
  142. package/elysia/src/routes/ssr.d.ts +1 -1
  143. package/elysia/src/routes/ssr.d.ts.map +1 -1
  144. package/elysia/src/routes/static.d.ts +1 -1
  145. package/elysia/src/routes/themeCssRefresh.d.ts +1 -1
  146. package/elysia/src/types.d.ts +1 -1
  147. package/package.json +1 -1
  148. package/react/index.d.ts +1 -1
  149. package/react/index.js +13 -27
  150. package/react/index.js.map +4 -4
  151. package/react/src/components/ClientOnly.d.ts +1 -1
  152. package/react/src/components/ContentRoute.d.ts +1 -1
  153. package/react/src/components/Image.d.ts +1 -1
  154. package/react/src/components/LazyRoute.d.ts +1 -1
  155. package/react/src/components/Link.d.ts +1 -1
  156. package/react/src/components/Markdown.d.ts +1 -1
  157. package/react/src/components/Outlet.d.ts +1 -1
  158. package/react/src/components/index.d.ts +1 -1
  159. package/react/src/hooks/index.d.ts +1 -1
  160. package/react/src/hooks/useContent.d.ts +1 -1
  161. package/react/src/hooks/useContent.d.ts.map +1 -1
  162. package/react/src/hooks/useData.d.ts +1 -1
  163. package/react/src/hooks/useFeed.d.ts +1 -1
  164. package/react/src/hooks/useLayoutData.d.ts +1 -1
  165. package/react/src/hooks/useLlms.d.ts +1 -1
  166. package/react/src/hooks/useNavigate.d.ts +1 -1
  167. package/react/src/hooks/useParams.d.ts +1 -1
  168. package/react/src/hooks/useRouter.d.ts +1 -1
  169. package/react/src/hooks/useSearch.d.ts +1 -1
  170. package/react/src/hooks/useSearchParams.d.ts +1 -1
  171. package/react/src/hooks/useToc.d.ts +1 -1
  172. package/react/src/i18n/LocaleProvider.d.ts +1 -1
  173. package/react/src/i18n/LocaleProvider.d.ts.map +1 -1
  174. package/react/src/i18n/helpers.d.ts +1 -1
  175. package/react/src/i18n/index.d.ts +1 -1
  176. package/react/src/index.d.ts +1 -1
  177. package/react/src/lib/collection.d.ts +1 -1
  178. package/react/src/lib/content.d.ts +1 -1
  179. package/react/src/lib/head.d.ts +1 -1
  180. package/react/src/lib/index.d.ts +1 -1
  181. package/react/src/lib/lazy-route.d.ts +1 -1
  182. package/react/src/lib/route-loader.d.ts +1 -1
  183. package/react/src/providers/ContentProvider.d.ts +1 -1
  184. package/react/src/providers/RerouteProvider.d.ts +1 -1
  185. package/react/src/providers/RouterProvider.d.ts +1 -1
  186. package/react/src/providers/index.d.ts +1 -1
  187. package/react/src/types/any.d.ts +1 -1
  188. package/react/src/types/index.d.ts +1 -1
  189. package/react/src/types/router.d.ts +1 -1
  190. package/telemetry/react.d.ts +1 -1
  191. package/telemetry/react.js +2 -2
  192. package/telemetry/react.js.map +1 -1
  193. package/telemetry/server.d.ts +1 -1
  194. package/telemetry/server.js +2 -2
  195. package/telemetry/server.js.map +8 -8
  196. package/telemetry/src/react/api.d.ts +1 -1
  197. package/telemetry/src/react/context.d.ts +1 -1
  198. package/telemetry/src/react/index.d.ts +1 -1
  199. package/telemetry/src/react/telemetry.d.ts +1 -1
  200. package/telemetry/src/server/context.d.ts +1 -1
  201. package/telemetry/src/server/headers/extractor.d.ts +1 -1
  202. package/telemetry/src/server/headers/index.d.ts +1 -1
  203. package/telemetry/src/server/headers/presets.d.ts +1 -1
  204. package/telemetry/src/server/index.d.ts +1 -1
  205. package/telemetry/src/server/instrumentation.d.ts +1 -1
  206. package/telemetry/src/server/plugin.d.ts +1 -1
  207. package/telemetry/src/server/sourcemap.d.ts +1 -1
package/core/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * reroute-js v1.0.0-alpha.6
2
+ * reroute-js v1.0.0-alpha.8
3
3
  *
4
4
  * @license MIT
5
5
  * @copyright 2026 stewones <hi@stewan.io>
@@ -480,9 +480,30 @@ function hreflangTags(baseUrl, collection, name, locales, defaultLocale) {
480
480
  var init_pathname = () => {};
481
481
 
482
482
  // packages/core/src/i18n/resolve.ts
483
+ function canonicalLocale(value, availableLocales) {
484
+ return availableLocales.find((l) => l.toLowerCase() === value.toLowerCase()) || value;
485
+ }
486
+ function parseLangParam(search, isAvailable, availableLocales) {
487
+ if (!search)
488
+ return;
489
+ const params = new URLSearchParams(search.startsWith("?") ? search.slice(1) : search);
490
+ const raw = params.get("lang") ?? undefined;
491
+ if (!isAvailable(raw))
492
+ return;
493
+ return canonicalLocale(raw, availableLocales);
494
+ }
495
+ function stripLangParam(search) {
496
+ if (!search)
497
+ return "";
498
+ const params = new URLSearchParams(search.startsWith("?") ? search.slice(1) : search);
499
+ params.delete("lang");
500
+ const rest = params.toString();
501
+ return rest ? `?${rest}` : "";
502
+ }
483
503
  function resolveLocale(input) {
484
504
  const {
485
505
  pathname,
506
+ search,
486
507
  cookieHeader,
487
508
  acceptLanguage,
488
509
  availableLocales,
@@ -493,14 +514,32 @@ function resolveLocale(input) {
493
514
  const parsed = parseContentPath(pathname, availableLocales, collections);
494
515
  const availableLower = new Set(availableLocales.map((l) => l.toLowerCase()));
495
516
  const isAvailable = (locale) => !!locale && availableLower.has(locale.toLowerCase());
517
+ const routingPathname = parsed?.routingPathname ?? pathname.split("?")[0];
518
+ const restSearch = stripLangParam(search);
519
+ const queryLocale = parseLangParam(search, isAvailable, availableLocales);
520
+ if (queryLocale) {
521
+ const target = parsed ? localizeContentHref(parsed.collection, parsed.name, queryLocale, defaultLocale) : routingPathname;
522
+ return {
523
+ locale: queryLocale,
524
+ routingPathname,
525
+ fromPath: false,
526
+ fromQuery: true,
527
+ redirectTo: `${target}${restSearch}`,
528
+ parsed: parsed ? {
529
+ ...parsed,
530
+ locale: queryLocale === defaultLocale ? undefined : queryLocale
531
+ } : undefined
532
+ };
533
+ }
496
534
  if (parsed?.locale && isAvailable(parsed.locale)) {
497
- const locale = availableLocales.find((l) => l.toLowerCase() === parsed.locale?.toLowerCase()) || parsed.locale;
535
+ const locale = canonicalLocale(parsed.locale, availableLocales);
498
536
  if (locale === defaultLocale && parsed.pathname !== parsed.routingPathname) {
499
537
  return {
500
538
  locale,
501
539
  routingPathname: parsed.routingPathname,
502
540
  fromPath: true,
503
- redirectTo: parsed.routingPathname,
541
+ fromQuery: false,
542
+ redirectTo: `${parsed.routingPathname}${restSearch}`,
504
543
  parsed: { ...parsed, locale }
505
544
  };
506
545
  }
@@ -508,17 +547,18 @@ function resolveLocale(input) {
508
547
  locale,
509
548
  routingPathname: parsed.routingPathname,
510
549
  fromPath: true,
550
+ fromQuery: false,
511
551
  parsed: { ...parsed, locale }
512
552
  };
513
553
  }
514
- const routingPathname = parsed?.routingPathname ?? pathname.split("?")[0];
515
554
  const cookieLocale = parseCookieValue(cookieHeader, cookieName);
516
555
  if (isAvailable(cookieLocale)) {
517
- const locale = availableLocales.find((l) => l.toLowerCase() === cookieLocale.toLowerCase()) || cookieLocale;
556
+ const locale = canonicalLocale(cookieLocale, availableLocales);
518
557
  return {
519
558
  locale,
520
559
  routingPathname,
521
560
  fromPath: false,
561
+ fromQuery: false,
522
562
  parsed: parsed ? { ...parsed, locale: undefined } : undefined
523
563
  };
524
564
  }
@@ -527,13 +567,14 @@ function resolveLocale(input) {
527
567
  locale: negotiated,
528
568
  routingPathname,
529
569
  fromPath: false,
570
+ fromQuery: false,
530
571
  parsed: parsed ? { ...parsed, locale: undefined } : undefined
531
572
  };
532
573
  }
533
574
  function contentNegotiateRedirect(resolution, defaultLocale, enabled) {
534
575
  if (!enabled)
535
576
  return;
536
- if (resolution.fromPath)
577
+ if (resolution.fromPath || resolution.fromQuery)
537
578
  return;
538
579
  if (resolution.locale === defaultLocale)
539
580
  return;
@@ -1109,6 +1150,21 @@ function setGlobalCollections(byCollectionForSSR) {
1109
1150
  globalThis.__REROUTE_COLLECTIONS__ = byCollectionForSSR;
1110
1151
  } catch {}
1111
1152
  }
1153
+ function resetSSRContentResults() {
1154
+ try {
1155
+ globalThis.__REROUTE_SSR_RESULTS__ = {};
1156
+ } catch {}
1157
+ }
1158
+ function takeSSRContentResults() {
1159
+ try {
1160
+ const g = globalThis;
1161
+ const results = g.__REROUTE_SSR_RESULTS__;
1162
+ g.__REROUTE_SSR_RESULTS__ = {};
1163
+ return results;
1164
+ } catch {
1165
+ return;
1166
+ }
1167
+ }
1112
1168
  var init_collections = __esm(() => {
1113
1169
  init_imports();
1114
1170
  });
@@ -3229,23 +3285,34 @@ function parseAccessTracking(accessedCollections) {
3229
3285
  }
3230
3286
  return usage;
3231
3287
  }
3232
- function processCollections(accessedCollections, byCollectionForSSR) {
3288
+ function processCapturedResults(capturedResults, byCollectionForSSR) {
3233
3289
  const subset = {};
3234
3290
  const partial = {};
3235
3291
  try {
3236
3292
  const g = globalThis;
3237
- const ssrResults = g.__REROUTE_SSR_RESULTS__;
3238
- if (ssrResults && typeof ssrResults === "object") {
3239
- for (const [collection, items] of Object.entries(ssrResults)) {
3240
- if (Array.isArray(items) && items.length > 0) {
3241
- subset[collection] = items;
3242
- const full = byCollectionForSSR?.[collection] || [];
3243
- partial[collection] = items.length < full.length;
3244
- }
3293
+ const ssrResults = capturedResults ?? g.__REROUTE_SSR_RESULTS__;
3294
+ if (!ssrResults || typeof ssrResults !== "object")
3295
+ return;
3296
+ for (const [collection, items] of Object.entries(ssrResults)) {
3297
+ if (Array.isArray(items) && items.length > 0) {
3298
+ subset[collection] = items;
3299
+ const full = byCollectionForSSR?.[collection] || [];
3300
+ partial[collection] = items.length < full.length;
3245
3301
  }
3246
- return { subset, partial };
3247
3302
  }
3248
- } catch {}
3303
+ } catch {
3304
+ return;
3305
+ }
3306
+ if (Object.keys(subset).length === 0)
3307
+ return;
3308
+ return { subset, partial };
3309
+ }
3310
+ function processCollections(accessedCollections, byCollectionForSSR, capturedResults) {
3311
+ const captured = processCapturedResults(capturedResults, byCollectionForSSR);
3312
+ if (captured)
3313
+ return captured;
3314
+ const subset = {};
3315
+ const partial = {};
3249
3316
  const sortByDate = (order) => (a, b) => {
3250
3317
  const da = a?.meta?.date ? Date.parse(String(a.meta.date)) : 0;
3251
3318
  const db = b?.meta?.date ? Date.parse(String(b.meta.date)) : 0;
@@ -3534,6 +3601,7 @@ async function performSSRSetupInternal(options, streaming, timeoutState) {
3534
3601
  });
3535
3602
  assertNotTimedOut();
3536
3603
  resetSSRAccessTracking();
3604
+ resetSSRContentResults();
3537
3605
  const bundlePreload = createBundlePreload(bundleUrl);
3538
3606
  const preloadResult = await withSpan("ssr.preload", async (span) => {
3539
3607
  span.setAttribute("pathname", pathname);
@@ -3609,12 +3677,12 @@ async function performSSRSetupInternal(options, streaming, timeoutState) {
3609
3677
  pending: computeResult.pending
3610
3678
  };
3611
3679
  }
3612
- function generateCollectionScripts(byCollectionForSSR) {
3680
+ function generateCollectionScripts(byCollectionForSSR, capturedResults) {
3613
3681
  try {
3614
3682
  const g = globalThis;
3615
3683
  const acc = g.__REROUTE_SSR_ACCESSED__;
3616
3684
  if (acc) {
3617
- const { subset, partial } = processCollections(acc, byCollectionForSSR);
3685
+ const { subset, partial } = processCollections(acc, byCollectionForSSR, capturedResults);
3618
3686
  if (Object.keys(subset).length > 0) {
3619
3687
  return createCollectionScript(subset, partial);
3620
3688
  }
@@ -3766,13 +3834,16 @@ async function renderSSRDocument(options) {
3766
3834
  }, false);
3767
3835
  const duplicatedData = duplicateQueryParamData(setup2.ssrData);
3768
3836
  setGlobalSSRData(duplicatedData);
3837
+ let capturedResults;
3769
3838
  const appHtml = await withSpan("ssr.render.react", async (span) => {
3770
3839
  const componentWithPathname = cloneElement(rootComponent, {
3771
3840
  pathname,
3772
3841
  searchParams
3773
3842
  });
3774
3843
  span.setAttribute("reroute.pathname", pathname);
3844
+ resetSSRContentResults();
3775
3845
  const html3 = renderToString(componentWithPathname);
3846
+ capturedResults = takeSSRContentResults();
3776
3847
  span.setAttribute("reroute.html.final.size", html3.length);
3777
3848
  return html3;
3778
3849
  });
@@ -3781,7 +3852,7 @@ async function renderSSRDocument(options) {
3781
3852
  span.setAttribute("reroute.template.size", template2.length);
3782
3853
  return template2;
3783
3854
  });
3784
- const collectionScripts = generateCollectionScripts(setup2.byCollectionForSSR);
3855
+ const collectionScripts = generateCollectionScripts(setup2.byCollectionForSSR, capturedResults);
3785
3856
  const config = await loadConfig(cwd);
3786
3857
  const browserTelemetryConfigRaw = config.telemetry?.browser;
3787
3858
  const { serializeBrowserTelemetryConfig: serializeBrowserTelemetryConfig2 } = await Promise.resolve().then(() => exports_serialize);
@@ -4164,6 +4235,25 @@ __export(exports_index_generator, {
4164
4235
  generateLLMsIndex: () => generateLLMsIndex
4165
4236
  });
4166
4237
  import { pathToFileURL as pathToFileURL6 } from "node:url";
4238
+ function oneLine(value) {
4239
+ return value.replace(/\s+/g, " ").trim();
4240
+ }
4241
+ function stringField(record, key) {
4242
+ const value = record?.[key];
4243
+ if (typeof value !== "string")
4244
+ return;
4245
+ const trimmed = oneLine(value);
4246
+ return trimmed.length > 0 ? trimmed : undefined;
4247
+ }
4248
+ function metaFromUnknown(meta) {
4249
+ if (!meta || typeof meta !== "object")
4250
+ return {};
4251
+ const record = meta;
4252
+ return {
4253
+ title: stringField(record, "title") ?? stringField(record, "name"),
4254
+ description: stringField(record, "description") ?? stringField(record, "excerpt")
4255
+ };
4256
+ }
4167
4257
  async function discoverStaticRoutes(cwd, isWatchMode) {
4168
4258
  const routes = [];
4169
4259
  try {
@@ -4180,8 +4270,11 @@ async function discoverStaticRoutes(cwd, isWatchMode) {
4180
4270
  if (pattern.includes("[404]") || pattern.includes("[layout]") || pattern.includes("[skeleton]") || pattern.includes(":")) {
4181
4271
  continue;
4182
4272
  }
4273
+ const { title, description } = metaFromUnknown(route?.meta);
4183
4274
  routes.push({
4184
- path: pattern
4275
+ path: pattern,
4276
+ title,
4277
+ description
4185
4278
  });
4186
4279
  }
4187
4280
  }
@@ -4204,11 +4297,13 @@ function createRouteEntriesFromItems(items, collection) {
4204
4297
  for (const item of items) {
4205
4298
  const href = String(item.href || "");
4206
4299
  if (href) {
4207
- const title = item.meta?.title || item.meta?.name || item.name;
4300
+ const fromMeta = metaFromUnknown(item.meta);
4301
+ const title = fromMeta.title || (typeof item.name === "string" ? item.name : undefined);
4208
4302
  routes.push({
4209
4303
  path: href,
4210
4304
  section: collection,
4211
- title
4305
+ title,
4306
+ description: fromMeta.description
4212
4307
  });
4213
4308
  }
4214
4309
  }
@@ -4274,9 +4369,13 @@ function createEntriesFromArray(array, routePath) {
4274
4369
  continue;
4275
4370
  const identifier = extractIdentifier(item);
4276
4371
  if (identifier) {
4372
+ const fromItem = metaFromUnknown(item);
4373
+ const fromMeta = metaFromUnknown(item.meta);
4277
4374
  entries.push({
4278
4375
  path: `${routePath}/${identifier}`,
4279
- section: routePath.split("/").filter(Boolean)[0]
4376
+ section: routePath.split("/").filter(Boolean)[0],
4377
+ title: fromItem.title ?? fromMeta.title,
4378
+ description: fromItem.description ?? fromMeta.description
4280
4379
  });
4281
4380
  }
4282
4381
  }
@@ -4382,13 +4481,21 @@ function formatRouteUrl(routePath, baseUrl) {
4382
4481
  function getRouteTitle(route) {
4383
4482
  return route.title || (route.path === "/" ? "Home" : route.path.split("/").pop() || "Page");
4384
4483
  }
4385
- function addRootRoutes(parts, rootRoutes, baseUrl, isScoped) {
4484
+ function formatIndexLine(route, url, summaries) {
4485
+ const link = `- [${getRouteTitle(route)}](${url})`;
4486
+ if (!(summaries && route.description))
4487
+ return link;
4488
+ return `${link}: ${route.description}`;
4489
+ }
4490
+ function summariesEnabled(llmsConfig) {
4491
+ return llmsConfig?.indexSummaries !== false;
4492
+ }
4493
+ function addRootRoutes(parts, rootRoutes, baseUrl, isScoped, llmsConfig) {
4386
4494
  if (isScoped || rootRoutes.length === 0)
4387
4495
  return;
4496
+ const summaries = summariesEnabled(llmsConfig);
4388
4497
  for (const route of rootRoutes) {
4389
- const title = getRouteTitle(route);
4390
- const url = formatRouteUrl(route.path, baseUrl);
4391
- parts.push(`- [${title}](${url})`);
4498
+ parts.push(formatIndexLine(route, formatRouteUrl(route.path, baseUrl), summaries));
4392
4499
  }
4393
4500
  parts.push("");
4394
4501
  }
@@ -4399,10 +4506,9 @@ function addCollectionSection(parts, collection, routes, baseUrl, llmsConfig) {
4399
4506
  const sectionName = collection.charAt(0).toUpperCase() + collection.slice(1);
4400
4507
  parts.push(`## ${sectionName}`);
4401
4508
  parts.push("");
4509
+ const summaries = summariesEnabled(llmsConfig);
4402
4510
  for (const route of filteredRoutes) {
4403
- const title = route.title || route.path.split("/").pop() || "Untitled";
4404
- const url = `${baseUrl}${route.path}.txt`;
4405
- parts.push(`- [${title}](${url})`);
4511
+ parts.push(formatIndexLine(route, `${baseUrl}${route.path}.txt`, summaries));
4406
4512
  }
4407
4513
  parts.push("");
4408
4514
  }
@@ -4420,10 +4526,9 @@ function addSSRDataSection(parts, routePattern, routes, baseUrl, isScoped, targe
4420
4526
  const sectionName = routeSection?.charAt(0).toUpperCase() + routeSection?.slice(1) || "Content";
4421
4527
  parts.push(`## ${sectionName}`);
4422
4528
  parts.push("");
4529
+ const summaries = summariesEnabled(llmsConfig);
4423
4530
  for (const route of filteredRoutes) {
4424
- const title = route.title || route.path.split("/").pop() || "Untitled";
4425
- const url = `${baseUrl}${route.path}.txt`;
4426
- parts.push(`- [${title}](${url})`);
4531
+ parts.push(formatIndexLine(route, `${baseUrl}${route.path}.txt`, summaries));
4427
4532
  }
4428
4533
  parts.push("");
4429
4534
  }
@@ -4437,10 +4542,9 @@ function addStaticSection(parts, section, routes, baseUrl, isScoped, targetColle
4437
4542
  const sectionName = section.charAt(0).toUpperCase() + section.slice(1);
4438
4543
  parts.push(`## ${sectionName}`);
4439
4544
  parts.push("");
4545
+ const summaries = summariesEnabled(llmsConfig);
4440
4546
  for (const route of filteredRoutes) {
4441
- const title = route.title || route.path.split("/").pop() || "Untitled";
4442
- const url = `${baseUrl}${route.path}.txt`;
4443
- parts.push(`- [${title}](${url})`);
4547
+ parts.push(formatIndexLine(route, `${baseUrl}${route.path}.txt`, summaries));
4444
4548
  }
4445
4549
  parts.push("");
4446
4550
  }
@@ -4454,7 +4558,7 @@ async function generateLLMsIndex(options) {
4454
4558
  const collectionsMap = await discoverCollectionRoutes(cwd, collections2, isWatchMode, llmsConfig);
4455
4559
  const ssrDataRoutes = await discoverSSRDataRoutes(cwd, staticRoutes, isWatchMode);
4456
4560
  const { sections, rootRoutes } = groupStaticRoutes(staticRoutes, llmsConfig);
4457
- addRootRoutes(parts, rootRoutes, baseUrl, isScoped);
4561
+ addRootRoutes(parts, rootRoutes, baseUrl, isScoped, llmsConfig);
4458
4562
  for (const [collection, routes] of collectionsMap.entries()) {
4459
4563
  if (routes.length > 0) {
4460
4564
  addCollectionSection(parts, collection, routes, baseUrl, llmsConfig);
@@ -4473,9 +4577,6 @@ async function generateLLMsIndex(options) {
4473
4577
  parts.push("---");
4474
4578
  parts.push("");
4475
4579
  parts.push("Formats: .txt | .md | Accept: text/plain | Accept: text/markdown");
4476
- if (!isScoped && baseUrl) {
4477
- parts.push(`Full dump: ${baseUrl}/llms-full.txt`);
4478
- }
4479
4580
  return parts.join(`
4480
4581
  `);
4481
4582
  }
@@ -6362,6 +6463,7 @@ export {
6362
6463
  renderSSRDocument,
6363
6464
  renderSSRDocumentStream,
6364
6465
  resetSSRAccessTracking,
6466
+ resetSSRContentResults,
6365
6467
  resolveLocale,
6366
6468
  seedSSRModuleForPath,
6367
6469
  setGlobalCollections,
@@ -6373,9 +6475,10 @@ export {
6373
6475
  stripEnd,
6374
6476
  stripHtmlTags,
6375
6477
  stripStart,
6478
+ takeSSRContentResults,
6376
6479
  toBytes,
6377
6480
  toOgLocale,
6378
6481
  toPromise
6379
6482
  };
6380
6483
 
6381
- //# debugId=F25428F1DCD3BB1C64756E2164756E21
6484
+ //# debugId=1C9333145BC7006164756E2164756E21