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/README.md CHANGED
@@ -670,7 +670,9 @@ src/client/routes/blog/content/
670
670
  - Flat files under `content/` are the default locale; nest under `content/{locale}/` for translations
671
671
  - Collections without locale folders behave as before
672
672
  - Default-locale prefix (`/blog/en-US/...`) 302s to the unprefixed URL
673
- - Optional negotiate: `Accept-Language` / cookie can 302 default content URLs to a localized path (`i18n.redirectContentOnNegotiate`, default `true`)
673
+ - A locale segment in the URL always wins over cookie / `Accept-Language`
674
+ - `setLocale()` writes `?lang=` and the server 302s to the canonical content URL (and sets the cookie). That is the only way to leave a URL that already has a locale in the path
675
+ - Optional negotiate: `Accept-Language` / cookie can 302 **unprefixed** content URLs to a localized path (`i18n.redirectContentOnNegotiate`, default `true`)
674
676
 
675
677
  ### UI Strings
676
678
 
@@ -1165,8 +1167,8 @@ export default defineConfig({
1165
1167
  Your site now supports:
1166
1168
  - `.txt` and `.md` extensions on any route (e.g., `/blog/post.txt`, `/about.md`)
1167
1169
  - Accept header content negotiation (`Accept: text/plain`, `Accept: text/markdown`)
1168
- - `/llms.txt` - Index of all content organized by section
1169
- - `/llms-full.txt` - Complete site content in one file
1170
+ - `/llms.txt` - Index of all content: title, description, and link per page
1171
+ - `/llms-full.txt` - Complete site content in one file (optional; large)
1170
1172
 
1171
1173
  #### How It Works
1172
1174
 
package/cli/bin.d.ts 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>
package/cli/bin.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
3
  /**
4
- * reroute-js v1.0.0-alpha.6
4
+ * reroute-js v1.0.0-alpha.8
5
5
  *
6
6
  * @license MIT
7
7
  * @copyright 2026 stewones <hi@stewan.io>
@@ -68,7 +68,7 @@ async function getVersionString() {
68
68
  }
69
69
  async function getVersion() {
70
70
  if (true) {
71
- return "1.0.0-alpha.6";
71
+ return "1.0.0-alpha.8";
72
72
  }
73
73
  const possiblePaths = [
74
74
  path.join(import.meta.dir, "../../../../package.json"),
@@ -86,7 +86,7 @@ async function getVersion() {
86
86
  }
87
87
  async function getCommit() {
88
88
  if (true) {
89
- return "1f58c52";
89
+ return "2c48a1e";
90
90
  }
91
91
  return "dev";
92
92
  }
@@ -818,9 +818,30 @@ function hreflangTags(baseUrl, collection, name, locales, defaultLocale) {
818
818
  var init_pathname = () => {};
819
819
 
820
820
  // packages/core/src/i18n/resolve.ts
821
+ function canonicalLocale(value, availableLocales) {
822
+ return availableLocales.find((l) => l.toLowerCase() === value.toLowerCase()) || value;
823
+ }
824
+ function parseLangParam(search, isAvailable, availableLocales) {
825
+ if (!search)
826
+ return;
827
+ const params = new URLSearchParams(search.startsWith("?") ? search.slice(1) : search);
828
+ const raw = params.get("lang") ?? undefined;
829
+ if (!isAvailable(raw))
830
+ return;
831
+ return canonicalLocale(raw, availableLocales);
832
+ }
833
+ function stripLangParam(search) {
834
+ if (!search)
835
+ return "";
836
+ const params = new URLSearchParams(search.startsWith("?") ? search.slice(1) : search);
837
+ params.delete("lang");
838
+ const rest = params.toString();
839
+ return rest ? `?${rest}` : "";
840
+ }
821
841
  function resolveLocale(input) {
822
842
  const {
823
843
  pathname,
844
+ search,
824
845
  cookieHeader,
825
846
  acceptLanguage,
826
847
  availableLocales,
@@ -831,14 +852,32 @@ function resolveLocale(input) {
831
852
  const parsed = parseContentPath(pathname, availableLocales, collections);
832
853
  const availableLower = new Set(availableLocales.map((l) => l.toLowerCase()));
833
854
  const isAvailable = (locale) => !!locale && availableLower.has(locale.toLowerCase());
855
+ const routingPathname = parsed?.routingPathname ?? pathname.split("?")[0];
856
+ const restSearch = stripLangParam(search);
857
+ const queryLocale = parseLangParam(search, isAvailable, availableLocales);
858
+ if (queryLocale) {
859
+ const target = parsed ? localizeContentHref(parsed.collection, parsed.name, queryLocale, defaultLocale) : routingPathname;
860
+ return {
861
+ locale: queryLocale,
862
+ routingPathname,
863
+ fromPath: false,
864
+ fromQuery: true,
865
+ redirectTo: `${target}${restSearch}`,
866
+ parsed: parsed ? {
867
+ ...parsed,
868
+ locale: queryLocale === defaultLocale ? undefined : queryLocale
869
+ } : undefined
870
+ };
871
+ }
834
872
  if (parsed?.locale && isAvailable(parsed.locale)) {
835
- const locale = availableLocales.find((l) => l.toLowerCase() === parsed.locale?.toLowerCase()) || parsed.locale;
873
+ const locale = canonicalLocale(parsed.locale, availableLocales);
836
874
  if (locale === defaultLocale && parsed.pathname !== parsed.routingPathname) {
837
875
  return {
838
876
  locale,
839
877
  routingPathname: parsed.routingPathname,
840
878
  fromPath: true,
841
- redirectTo: parsed.routingPathname,
879
+ fromQuery: false,
880
+ redirectTo: `${parsed.routingPathname}${restSearch}`,
842
881
  parsed: { ...parsed, locale }
843
882
  };
844
883
  }
@@ -846,17 +885,18 @@ function resolveLocale(input) {
846
885
  locale,
847
886
  routingPathname: parsed.routingPathname,
848
887
  fromPath: true,
888
+ fromQuery: false,
849
889
  parsed: { ...parsed, locale }
850
890
  };
851
891
  }
852
- const routingPathname = parsed?.routingPathname ?? pathname.split("?")[0];
853
892
  const cookieLocale = parseCookieValue(cookieHeader, cookieName);
854
893
  if (isAvailable(cookieLocale)) {
855
- const locale = availableLocales.find((l) => l.toLowerCase() === cookieLocale.toLowerCase()) || cookieLocale;
894
+ const locale = canonicalLocale(cookieLocale, availableLocales);
856
895
  return {
857
896
  locale,
858
897
  routingPathname,
859
898
  fromPath: false,
899
+ fromQuery: false,
860
900
  parsed: parsed ? { ...parsed, locale: undefined } : undefined
861
901
  };
862
902
  }
@@ -865,13 +905,14 @@ function resolveLocale(input) {
865
905
  locale: negotiated,
866
906
  routingPathname,
867
907
  fromPath: false,
908
+ fromQuery: false,
868
909
  parsed: parsed ? { ...parsed, locale: undefined } : undefined
869
910
  };
870
911
  }
871
912
  function contentNegotiateRedirect(resolution, defaultLocale, enabled) {
872
913
  if (!enabled)
873
914
  return;
874
- if (resolution.fromPath)
915
+ if (resolution.fromPath || resolution.fromQuery)
875
916
  return;
876
917
  if (resolution.locale === defaultLocale)
877
918
  return;
@@ -1447,6 +1488,21 @@ function setGlobalCollections(byCollectionForSSR) {
1447
1488
  globalThis.__REROUTE_COLLECTIONS__ = byCollectionForSSR;
1448
1489
  } catch {}
1449
1490
  }
1491
+ function resetSSRContentResults() {
1492
+ try {
1493
+ globalThis.__REROUTE_SSR_RESULTS__ = {};
1494
+ } catch {}
1495
+ }
1496
+ function takeSSRContentResults() {
1497
+ try {
1498
+ const g = globalThis;
1499
+ const results = g.__REROUTE_SSR_RESULTS__;
1500
+ g.__REROUTE_SSR_RESULTS__ = {};
1501
+ return results;
1502
+ } catch {
1503
+ return;
1504
+ }
1505
+ }
1450
1506
  var init_collections = __esm(() => {
1451
1507
  init_imports();
1452
1508
  });
@@ -3567,23 +3623,34 @@ function parseAccessTracking(accessedCollections) {
3567
3623
  }
3568
3624
  return usage;
3569
3625
  }
3570
- function processCollections(accessedCollections, byCollectionForSSR) {
3626
+ function processCapturedResults(capturedResults, byCollectionForSSR) {
3571
3627
  const subset = {};
3572
3628
  const partial = {};
3573
3629
  try {
3574
3630
  const g = globalThis;
3575
- const ssrResults = g.__REROUTE_SSR_RESULTS__;
3576
- if (ssrResults && typeof ssrResults === "object") {
3577
- for (const [collection, items] of Object.entries(ssrResults)) {
3578
- if (Array.isArray(items) && items.length > 0) {
3579
- subset[collection] = items;
3580
- const full = byCollectionForSSR?.[collection] || [];
3581
- partial[collection] = items.length < full.length;
3582
- }
3631
+ const ssrResults = capturedResults ?? g.__REROUTE_SSR_RESULTS__;
3632
+ if (!ssrResults || typeof ssrResults !== "object")
3633
+ return;
3634
+ for (const [collection, items] of Object.entries(ssrResults)) {
3635
+ if (Array.isArray(items) && items.length > 0) {
3636
+ subset[collection] = items;
3637
+ const full = byCollectionForSSR?.[collection] || [];
3638
+ partial[collection] = items.length < full.length;
3583
3639
  }
3584
- return { subset, partial };
3585
3640
  }
3586
- } catch {}
3641
+ } catch {
3642
+ return;
3643
+ }
3644
+ if (Object.keys(subset).length === 0)
3645
+ return;
3646
+ return { subset, partial };
3647
+ }
3648
+ function processCollections(accessedCollections, byCollectionForSSR, capturedResults) {
3649
+ const captured = processCapturedResults(capturedResults, byCollectionForSSR);
3650
+ if (captured)
3651
+ return captured;
3652
+ const subset = {};
3653
+ const partial = {};
3587
3654
  const sortByDate = (order) => (a, b) => {
3588
3655
  const da = a?.meta?.date ? Date.parse(String(a.meta.date)) : 0;
3589
3656
  const db = b?.meta?.date ? Date.parse(String(b.meta.date)) : 0;
@@ -3872,6 +3939,7 @@ async function performSSRSetupInternal(options, streaming, timeoutState) {
3872
3939
  });
3873
3940
  assertNotTimedOut();
3874
3941
  resetSSRAccessTracking();
3942
+ resetSSRContentResults();
3875
3943
  const bundlePreload = createBundlePreload(bundleUrl);
3876
3944
  const preloadResult = await withSpan("ssr.preload", async (span) => {
3877
3945
  span.setAttribute("pathname", pathname);
@@ -3947,12 +4015,12 @@ async function performSSRSetupInternal(options, streaming, timeoutState) {
3947
4015
  pending: computeResult.pending
3948
4016
  };
3949
4017
  }
3950
- function generateCollectionScripts(byCollectionForSSR) {
4018
+ function generateCollectionScripts(byCollectionForSSR, capturedResults) {
3951
4019
  try {
3952
4020
  const g = globalThis;
3953
4021
  const acc = g.__REROUTE_SSR_ACCESSED__;
3954
4022
  if (acc) {
3955
- const { subset, partial } = processCollections(acc, byCollectionForSSR);
4023
+ const { subset, partial } = processCollections(acc, byCollectionForSSR, capturedResults);
3956
4024
  if (Object.keys(subset).length > 0) {
3957
4025
  return createCollectionScript(subset, partial);
3958
4026
  }
@@ -4104,13 +4172,16 @@ async function renderSSRDocument(options) {
4104
4172
  }, false);
4105
4173
  const duplicatedData = duplicateQueryParamData(setup2.ssrData);
4106
4174
  setGlobalSSRData(duplicatedData);
4175
+ let capturedResults;
4107
4176
  const appHtml = await withSpan("ssr.render.react", async (span) => {
4108
4177
  const componentWithPathname = cloneElement(rootComponent, {
4109
4178
  pathname,
4110
4179
  searchParams
4111
4180
  });
4112
4181
  span.setAttribute("reroute.pathname", pathname);
4182
+ resetSSRContentResults();
4113
4183
  const html3 = renderToString(componentWithPathname);
4184
+ capturedResults = takeSSRContentResults();
4114
4185
  span.setAttribute("reroute.html.final.size", html3.length);
4115
4186
  return html3;
4116
4187
  });
@@ -4119,7 +4190,7 @@ async function renderSSRDocument(options) {
4119
4190
  span.setAttribute("reroute.template.size", template2.length);
4120
4191
  return template2;
4121
4192
  });
4122
- const collectionScripts = generateCollectionScripts(setup2.byCollectionForSSR);
4193
+ const collectionScripts = generateCollectionScripts(setup2.byCollectionForSSR, capturedResults);
4123
4194
  const config = await loadConfig(cwd);
4124
4195
  const browserTelemetryConfigRaw = config.telemetry?.browser;
4125
4196
  const { serializeBrowserTelemetryConfig: serializeBrowserTelemetryConfig2 } = await Promise.resolve().then(() => exports_serialize);
@@ -4502,6 +4573,25 @@ __export(exports_index_generator, {
4502
4573
  generateLLMsIndex: () => generateLLMsIndex
4503
4574
  });
4504
4575
  import { pathToFileURL as pathToFileURL6 } from "node:url";
4576
+ function oneLine(value) {
4577
+ return value.replace(/\s+/g, " ").trim();
4578
+ }
4579
+ function stringField(record, key) {
4580
+ const value = record?.[key];
4581
+ if (typeof value !== "string")
4582
+ return;
4583
+ const trimmed = oneLine(value);
4584
+ return trimmed.length > 0 ? trimmed : undefined;
4585
+ }
4586
+ function metaFromUnknown(meta) {
4587
+ if (!meta || typeof meta !== "object")
4588
+ return {};
4589
+ const record = meta;
4590
+ return {
4591
+ title: stringField(record, "title") ?? stringField(record, "name"),
4592
+ description: stringField(record, "description") ?? stringField(record, "excerpt")
4593
+ };
4594
+ }
4505
4595
  async function discoverStaticRoutes(cwd, isWatchMode) {
4506
4596
  const routes = [];
4507
4597
  try {
@@ -4518,8 +4608,11 @@ async function discoverStaticRoutes(cwd, isWatchMode) {
4518
4608
  if (pattern.includes("[404]") || pattern.includes("[layout]") || pattern.includes("[skeleton]") || pattern.includes(":")) {
4519
4609
  continue;
4520
4610
  }
4611
+ const { title, description } = metaFromUnknown(route?.meta);
4521
4612
  routes.push({
4522
- path: pattern
4613
+ path: pattern,
4614
+ title,
4615
+ description
4523
4616
  });
4524
4617
  }
4525
4618
  }
@@ -4542,11 +4635,13 @@ function createRouteEntriesFromItems(items, collection) {
4542
4635
  for (const item of items) {
4543
4636
  const href = String(item.href || "");
4544
4637
  if (href) {
4545
- const title = item.meta?.title || item.meta?.name || item.name;
4638
+ const fromMeta = metaFromUnknown(item.meta);
4639
+ const title = fromMeta.title || (typeof item.name === "string" ? item.name : undefined);
4546
4640
  routes.push({
4547
4641
  path: href,
4548
4642
  section: collection,
4549
- title
4643
+ title,
4644
+ description: fromMeta.description
4550
4645
  });
4551
4646
  }
4552
4647
  }
@@ -4612,9 +4707,13 @@ function createEntriesFromArray(array, routePath) {
4612
4707
  continue;
4613
4708
  const identifier = extractIdentifier(item);
4614
4709
  if (identifier) {
4710
+ const fromItem = metaFromUnknown(item);
4711
+ const fromMeta = metaFromUnknown(item.meta);
4615
4712
  entries.push({
4616
4713
  path: `${routePath}/${identifier}`,
4617
- section: routePath.split("/").filter(Boolean)[0]
4714
+ section: routePath.split("/").filter(Boolean)[0],
4715
+ title: fromItem.title ?? fromMeta.title,
4716
+ description: fromItem.description ?? fromMeta.description
4618
4717
  });
4619
4718
  }
4620
4719
  }
@@ -4720,13 +4819,21 @@ function formatRouteUrl(routePath, baseUrl) {
4720
4819
  function getRouteTitle(route) {
4721
4820
  return route.title || (route.path === "/" ? "Home" : route.path.split("/").pop() || "Page");
4722
4821
  }
4723
- function addRootRoutes(parts, rootRoutes, baseUrl, isScoped) {
4822
+ function formatIndexLine(route, url, summaries) {
4823
+ const link = `- [${getRouteTitle(route)}](${url})`;
4824
+ if (!(summaries && route.description))
4825
+ return link;
4826
+ return `${link}: ${route.description}`;
4827
+ }
4828
+ function summariesEnabled(llmsConfig) {
4829
+ return llmsConfig?.indexSummaries !== false;
4830
+ }
4831
+ function addRootRoutes(parts, rootRoutes, baseUrl, isScoped, llmsConfig) {
4724
4832
  if (isScoped || rootRoutes.length === 0)
4725
4833
  return;
4834
+ const summaries = summariesEnabled(llmsConfig);
4726
4835
  for (const route of rootRoutes) {
4727
- const title = getRouteTitle(route);
4728
- const url = formatRouteUrl(route.path, baseUrl);
4729
- parts.push(`- [${title}](${url})`);
4836
+ parts.push(formatIndexLine(route, formatRouteUrl(route.path, baseUrl), summaries));
4730
4837
  }
4731
4838
  parts.push("");
4732
4839
  }
@@ -4737,10 +4844,9 @@ function addCollectionSection(parts, collection, routes, baseUrl, llmsConfig) {
4737
4844
  const sectionName = collection.charAt(0).toUpperCase() + collection.slice(1);
4738
4845
  parts.push(`## ${sectionName}`);
4739
4846
  parts.push("");
4847
+ const summaries = summariesEnabled(llmsConfig);
4740
4848
  for (const route of filteredRoutes) {
4741
- const title = route.title || route.path.split("/").pop() || "Untitled";
4742
- const url = `${baseUrl}${route.path}.txt`;
4743
- parts.push(`- [${title}](${url})`);
4849
+ parts.push(formatIndexLine(route, `${baseUrl}${route.path}.txt`, summaries));
4744
4850
  }
4745
4851
  parts.push("");
4746
4852
  }
@@ -4758,10 +4864,9 @@ function addSSRDataSection(parts, routePattern, routes, baseUrl, isScoped, targe
4758
4864
  const sectionName = routeSection?.charAt(0).toUpperCase() + routeSection?.slice(1) || "Content";
4759
4865
  parts.push(`## ${sectionName}`);
4760
4866
  parts.push("");
4867
+ const summaries = summariesEnabled(llmsConfig);
4761
4868
  for (const route of filteredRoutes) {
4762
- const title = route.title || route.path.split("/").pop() || "Untitled";
4763
- const url = `${baseUrl}${route.path}.txt`;
4764
- parts.push(`- [${title}](${url})`);
4869
+ parts.push(formatIndexLine(route, `${baseUrl}${route.path}.txt`, summaries));
4765
4870
  }
4766
4871
  parts.push("");
4767
4872
  }
@@ -4775,10 +4880,9 @@ function addStaticSection(parts, section, routes, baseUrl, isScoped, targetColle
4775
4880
  const sectionName = section.charAt(0).toUpperCase() + section.slice(1);
4776
4881
  parts.push(`## ${sectionName}`);
4777
4882
  parts.push("");
4883
+ const summaries = summariesEnabled(llmsConfig);
4778
4884
  for (const route of filteredRoutes) {
4779
- const title = route.title || route.path.split("/").pop() || "Untitled";
4780
- const url = `${baseUrl}${route.path}.txt`;
4781
- parts.push(`- [${title}](${url})`);
4885
+ parts.push(formatIndexLine(route, `${baseUrl}${route.path}.txt`, summaries));
4782
4886
  }
4783
4887
  parts.push("");
4784
4888
  }
@@ -4792,7 +4896,7 @@ async function generateLLMsIndex(options) {
4792
4896
  const collectionsMap = await discoverCollectionRoutes(cwd, collections2, isWatchMode, llmsConfig);
4793
4897
  const ssrDataRoutes = await discoverSSRDataRoutes(cwd, staticRoutes, isWatchMode);
4794
4898
  const { sections, rootRoutes } = groupStaticRoutes(staticRoutes, llmsConfig);
4795
- addRootRoutes(parts, rootRoutes, baseUrl, isScoped);
4899
+ addRootRoutes(parts, rootRoutes, baseUrl, isScoped, llmsConfig);
4796
4900
  for (const [collection, routes] of collectionsMap.entries()) {
4797
4901
  if (routes.length > 0) {
4798
4902
  addCollectionSection(parts, collection, routes, baseUrl, llmsConfig);
@@ -4811,9 +4915,6 @@ async function generateLLMsIndex(options) {
4811
4915
  parts.push("---");
4812
4916
  parts.push("");
4813
4917
  parts.push("Formats: .txt | .md | Accept: text/plain | Accept: text/markdown");
4814
- if (!isScoped && baseUrl) {
4815
- parts.push(`Full dump: ${baseUrl}/llms-full.txt`);
4816
- }
4817
4918
  return parts.join(`
4818
4919
  `);
4819
4920
  }
@@ -6696,6 +6797,7 @@ __export(exports_core, {
6696
6797
  renderSSRDocument: () => renderSSRDocument,
6697
6798
  renderSSRDocumentStream: () => renderSSRDocumentStream,
6698
6799
  resetSSRAccessTracking: () => resetSSRAccessTracking,
6800
+ resetSSRContentResults: () => resetSSRContentResults,
6699
6801
  resolveLocale: () => resolveLocale,
6700
6802
  seedSSRModuleForPath: () => seedSSRModuleForPath,
6701
6803
  setGlobalCollections: () => setGlobalCollections,
@@ -6707,6 +6809,7 @@ __export(exports_core, {
6707
6809
  stripEnd: () => stripEnd,
6708
6810
  stripHtmlTags: () => stripHtmlTags,
6709
6811
  stripStart: () => stripStart,
6812
+ takeSSRContentResults: () => takeSSRContentResults,
6710
6813
  toBytes: () => toBytes,
6711
6814
  toOgLocale: () => toOgLocale,
6712
6815
  toPromise: () => toPromise
@@ -107085,7 +107188,7 @@ async function getVersionString2() {
107085
107188
  }
107086
107189
  async function getVersion2() {
107087
107190
  if (true) {
107088
- return "1.0.0-alpha.6";
107191
+ return "1.0.0-alpha.8";
107089
107192
  }
107090
107193
  const possiblePaths = [
107091
107194
  path3.join(import.meta.dir, "../../../package.json"),
@@ -107102,10 +107205,10 @@ async function getVersion2() {
107102
107205
  }
107103
107206
  async function getCommit2() {
107104
107207
  if (true) {
107105
- return "1f58c52";
107208
+ return "2c48a1e";
107106
107209
  }
107107
107210
  return "dev";
107108
107211
  }
107109
107212
  main();
107110
107213
 
107111
- //# debugId=AFC08EDF211039B364756E2164756E21
107214
+ //# debugId=2ADD943B3E15E9F264756E2164756E21