reroute-js 1.0.0-alpha.5 → 1.0.0-alpha.7

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 (204) hide show
  1. package/README.md +5 -3
  2. package/cli/bin.d.ts +1 -1
  3. package/cli/bin.js +120 -41
  4. package/cli/bin.js.map +6 -6
  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 +116 -37
  36. package/core/index.js.map +6 -6
  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 +3 -1
  58. package/core/src/llms/full-generator.d.ts.map +1 -1
  59. package/core/src/llms/index-generator.d.ts +5 -2
  60. package/core/src/llms/index-generator.d.ts.map +1 -1
  61. package/core/src/llms/index.d.ts +1 -1
  62. package/core/src/og/discovery.d.ts +1 -1
  63. package/core/src/og/index.d.ts +1 -1
  64. package/core/src/og/meta.d.ts +1 -1
  65. package/core/src/og/render.d.ts +1 -1
  66. package/core/src/og/types.d.ts +1 -1
  67. package/core/src/robots/discovery.d.ts +1 -1
  68. package/core/src/robots/generator.d.ts +1 -1
  69. package/core/src/robots/index.d.ts +1 -1
  70. package/core/src/robots/policies.d.ts +1 -1
  71. package/core/src/rss/discovery.d.ts +1 -1
  72. package/core/src/rss/generator.d.ts +1 -1
  73. package/core/src/rss/index.d.ts +1 -1
  74. package/core/src/sitemap/discovery.d.ts +1 -1
  75. package/core/src/sitemap/generator.d.ts +1 -1
  76. package/core/src/sitemap/index.d.ts +1 -1
  77. package/core/src/ssr/index.d.ts +1 -1
  78. package/core/src/ssr/lib/cache.d.ts +1 -1
  79. package/core/src/ssr/lib/cleanup.d.ts +1 -1
  80. package/core/src/ssr/lib/collections.d.ts +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 +1 -1
  99. package/core/src/ssr/lib/scripts/data.d.ts +1 -1
  100. package/core/src/ssr/lib/scripts/escape.d.ts +1 -1
  101. package/core/src/ssr/lib/scripts/feeds.d.ts +1 -1
  102. package/core/src/ssr/lib/scripts/index.d.ts +1 -1
  103. package/core/src/ssr/lib/seed.d.ts +1 -1
  104. package/core/src/ssr/lib/serialize.d.ts +1 -1
  105. package/core/src/ssr/lib/setup.d.ts +1 -1
  106. package/core/src/ssr/lib/styles.d.ts +1 -1
  107. package/core/src/ssr/lib/template.d.ts +1 -1
  108. package/core/src/ssr/lib/types.d.ts +1 -1
  109. package/core/src/ssr/render.d.ts +1 -1
  110. package/core/src/ssr/stream.d.ts +1 -1
  111. package/elysia/index.d.ts +1 -1
  112. package/elysia/index.js +125 -42
  113. package/elysia/index.js.map +9 -9
  114. package/elysia/src/index.d.ts +1 -1
  115. package/elysia/src/libs/assets.d.ts +1 -1
  116. package/elysia/src/libs/cache.d.ts +1 -1
  117. package/elysia/src/libs/caching.d.ts +1 -1
  118. package/elysia/src/libs/http.d.ts +1 -1
  119. package/elysia/src/libs/i18n.d.ts +2 -2
  120. package/elysia/src/libs/i18n.d.ts.map +1 -1
  121. package/elysia/src/libs/image.d.ts +1 -1
  122. package/elysia/src/libs/index.d.ts +1 -1
  123. package/elysia/src/libs/llms.d.ts +1 -1
  124. package/elysia/src/libs/response.d.ts +1 -1
  125. package/elysia/src/libs/serving.d.ts +1 -1
  126. package/elysia/src/plugin.d.ts +1 -1
  127. package/elysia/src/routes/artifacts.d.ts +1 -1
  128. package/elysia/src/routes/content.d.ts +1 -1
  129. package/elysia/src/routes/image.d.ts +1 -1
  130. package/elysia/src/routes/index.d.ts +1 -1
  131. package/elysia/src/routes/internal.d.ts +1 -1
  132. package/elysia/src/routes/llms.d.ts +1 -1
  133. package/elysia/src/routes/llms.d.ts.map +1 -1
  134. package/elysia/src/routes/og.d.ts +1 -1
  135. package/elysia/src/routes/redirects.d.ts +1 -1
  136. package/elysia/src/routes/robots.d.ts +1 -1
  137. package/elysia/src/routes/rss.d.ts +1 -1
  138. package/elysia/src/routes/search.d.ts +1 -1
  139. package/elysia/src/routes/sitemap.d.ts +1 -1
  140. package/elysia/src/routes/ssr.d.ts +1 -1
  141. package/elysia/src/routes/ssr.d.ts.map +1 -1
  142. package/elysia/src/routes/static.d.ts +1 -1
  143. package/elysia/src/routes/themeCssRefresh.d.ts +1 -1
  144. package/elysia/src/types.d.ts +1 -1
  145. package/package.json +1 -1
  146. package/react/index.d.ts +1 -1
  147. package/react/index.js +7 -24
  148. package/react/index.js.map +3 -3
  149. package/react/src/components/ClientOnly.d.ts +1 -1
  150. package/react/src/components/ContentRoute.d.ts +1 -1
  151. package/react/src/components/Image.d.ts +1 -1
  152. package/react/src/components/LazyRoute.d.ts +1 -1
  153. package/react/src/components/Link.d.ts +1 -1
  154. package/react/src/components/Markdown.d.ts +1 -1
  155. package/react/src/components/Outlet.d.ts +1 -1
  156. package/react/src/components/index.d.ts +1 -1
  157. package/react/src/hooks/index.d.ts +1 -1
  158. package/react/src/hooks/useContent.d.ts +1 -1
  159. package/react/src/hooks/useData.d.ts +1 -1
  160. package/react/src/hooks/useFeed.d.ts +1 -1
  161. package/react/src/hooks/useLayoutData.d.ts +1 -1
  162. package/react/src/hooks/useLlms.d.ts +1 -1
  163. package/react/src/hooks/useNavigate.d.ts +1 -1
  164. package/react/src/hooks/useParams.d.ts +1 -1
  165. package/react/src/hooks/useRouter.d.ts +1 -1
  166. package/react/src/hooks/useSearch.d.ts +1 -1
  167. package/react/src/hooks/useSearchParams.d.ts +1 -1
  168. package/react/src/hooks/useToc.d.ts +1 -1
  169. package/react/src/i18n/LocaleProvider.d.ts +1 -1
  170. package/react/src/i18n/LocaleProvider.d.ts.map +1 -1
  171. package/react/src/i18n/helpers.d.ts +1 -1
  172. package/react/src/i18n/index.d.ts +1 -1
  173. package/react/src/index.d.ts +1 -1
  174. package/react/src/lib/collection.d.ts +1 -1
  175. package/react/src/lib/content.d.ts +1 -1
  176. package/react/src/lib/head.d.ts +1 -1
  177. package/react/src/lib/index.d.ts +1 -1
  178. package/react/src/lib/lazy-route.d.ts +1 -1
  179. package/react/src/lib/route-loader.d.ts +1 -1
  180. package/react/src/providers/ContentProvider.d.ts +1 -1
  181. package/react/src/providers/RerouteProvider.d.ts +1 -1
  182. package/react/src/providers/RouterProvider.d.ts +1 -1
  183. package/react/src/providers/index.d.ts +1 -1
  184. package/react/src/types/any.d.ts +1 -1
  185. package/react/src/types/index.d.ts +1 -1
  186. package/react/src/types/router.d.ts +1 -1
  187. package/telemetry/react.d.ts +1 -1
  188. package/telemetry/react.js +2 -2
  189. package/telemetry/react.js.map +1 -1
  190. package/telemetry/server.d.ts +1 -1
  191. package/telemetry/server.js +2 -2
  192. package/telemetry/server.js.map +6 -6
  193. package/telemetry/src/react/api.d.ts +1 -1
  194. package/telemetry/src/react/context.d.ts +1 -1
  195. package/telemetry/src/react/index.d.ts +1 -1
  196. package/telemetry/src/react/telemetry.d.ts +1 -1
  197. package/telemetry/src/server/context.d.ts +1 -1
  198. package/telemetry/src/server/headers/extractor.d.ts +1 -1
  199. package/telemetry/src/server/headers/index.d.ts +1 -1
  200. package/telemetry/src/server/headers/presets.d.ts +1 -1
  201. package/telemetry/src/server/index.d.ts +1 -1
  202. package/telemetry/src/server/instrumentation.d.ts +1 -1
  203. package/telemetry/src/server/plugin.d.ts +1 -1
  204. 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.5
2
+ * reroute-js v1.0.0-alpha.7
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.5
4
+ * reroute-js v1.0.0-alpha.7
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.5";
71
+ return "1.0.0-alpha.7";
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 "403cf32";
89
+ return "19dcaf7";
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;
@@ -4502,6 +4543,25 @@ __export(exports_index_generator, {
4502
4543
  generateLLMsIndex: () => generateLLMsIndex
4503
4544
  });
4504
4545
  import { pathToFileURL as pathToFileURL6 } from "node:url";
4546
+ function oneLine(value) {
4547
+ return value.replace(/\s+/g, " ").trim();
4548
+ }
4549
+ function stringField(record, key) {
4550
+ const value = record?.[key];
4551
+ if (typeof value !== "string")
4552
+ return;
4553
+ const trimmed = oneLine(value);
4554
+ return trimmed.length > 0 ? trimmed : undefined;
4555
+ }
4556
+ function metaFromUnknown(meta) {
4557
+ if (!meta || typeof meta !== "object")
4558
+ return {};
4559
+ const record = meta;
4560
+ return {
4561
+ title: stringField(record, "title") ?? stringField(record, "name"),
4562
+ description: stringField(record, "description") ?? stringField(record, "excerpt")
4563
+ };
4564
+ }
4505
4565
  async function discoverStaticRoutes(cwd, isWatchMode) {
4506
4566
  const routes = [];
4507
4567
  try {
@@ -4518,8 +4578,11 @@ async function discoverStaticRoutes(cwd, isWatchMode) {
4518
4578
  if (pattern.includes("[404]") || pattern.includes("[layout]") || pattern.includes("[skeleton]") || pattern.includes(":")) {
4519
4579
  continue;
4520
4580
  }
4581
+ const { title, description } = metaFromUnknown(route?.meta);
4521
4582
  routes.push({
4522
- path: pattern
4583
+ path: pattern,
4584
+ title,
4585
+ description
4523
4586
  });
4524
4587
  }
4525
4588
  }
@@ -4542,11 +4605,13 @@ function createRouteEntriesFromItems(items, collection) {
4542
4605
  for (const item of items) {
4543
4606
  const href = String(item.href || "");
4544
4607
  if (href) {
4545
- const title = item.meta?.title || item.meta?.name || item.name;
4608
+ const fromMeta = metaFromUnknown(item.meta);
4609
+ const title = fromMeta.title || (typeof item.name === "string" ? item.name : undefined);
4546
4610
  routes.push({
4547
4611
  path: href,
4548
4612
  section: collection,
4549
- title
4613
+ title,
4614
+ description: fromMeta.description
4550
4615
  });
4551
4616
  }
4552
4617
  }
@@ -4612,9 +4677,13 @@ function createEntriesFromArray(array, routePath) {
4612
4677
  continue;
4613
4678
  const identifier = extractIdentifier(item);
4614
4679
  if (identifier) {
4680
+ const fromItem = metaFromUnknown(item);
4681
+ const fromMeta = metaFromUnknown(item.meta);
4615
4682
  entries.push({
4616
4683
  path: `${routePath}/${identifier}`,
4617
- section: routePath.split("/").filter(Boolean)[0]
4684
+ section: routePath.split("/").filter(Boolean)[0],
4685
+ title: fromItem.title ?? fromMeta.title,
4686
+ description: fromItem.description ?? fromMeta.description
4618
4687
  });
4619
4688
  }
4620
4689
  }
@@ -4720,13 +4789,21 @@ function formatRouteUrl(routePath, baseUrl) {
4720
4789
  function getRouteTitle(route) {
4721
4790
  return route.title || (route.path === "/" ? "Home" : route.path.split("/").pop() || "Page");
4722
4791
  }
4723
- function addRootRoutes(parts, rootRoutes, baseUrl, isSingleCollection) {
4724
- if (isSingleCollection || rootRoutes.length === 0)
4792
+ function formatIndexLine(route, url, summaries) {
4793
+ const link = `- [${getRouteTitle(route)}](${url})`;
4794
+ if (!(summaries && route.description))
4795
+ return link;
4796
+ return `${link}: ${route.description}`;
4797
+ }
4798
+ function summariesEnabled(llmsConfig) {
4799
+ return llmsConfig?.indexSummaries !== false;
4800
+ }
4801
+ function addRootRoutes(parts, rootRoutes, baseUrl, isScoped, llmsConfig) {
4802
+ if (isScoped || rootRoutes.length === 0)
4725
4803
  return;
4804
+ const summaries = summariesEnabled(llmsConfig);
4726
4805
  for (const route of rootRoutes) {
4727
- const title = getRouteTitle(route);
4728
- const url = formatRouteUrl(route.path, baseUrl);
4729
- parts.push(`- [${title}](${url})`);
4806
+ parts.push(formatIndexLine(route, formatRouteUrl(route.path, baseUrl), summaries));
4730
4807
  }
4731
4808
  parts.push("");
4732
4809
  }
@@ -4737,19 +4814,18 @@ function addCollectionSection(parts, collection, routes, baseUrl, llmsConfig) {
4737
4814
  const sectionName = collection.charAt(0).toUpperCase() + collection.slice(1);
4738
4815
  parts.push(`## ${sectionName}`);
4739
4816
  parts.push("");
4817
+ const summaries = summariesEnabled(llmsConfig);
4740
4818
  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})`);
4819
+ parts.push(formatIndexLine(route, `${baseUrl}${route.path}.txt`, summaries));
4744
4820
  }
4745
4821
  parts.push("");
4746
4822
  }
4747
- function shouldIncludeSection(section, isSingleCollection, targetCollection) {
4748
- return !isSingleCollection || section === targetCollection;
4823
+ function shouldIncludeSection(section, isScoped, targetCollection) {
4824
+ return !isScoped || section === targetCollection;
4749
4825
  }
4750
- function addSSRDataSection(parts, routePattern, routes, baseUrl, isSingleCollection, targetCollection, llmsConfig) {
4826
+ function addSSRDataSection(parts, routePattern, routes, baseUrl, isScoped, targetCollection, llmsConfig) {
4751
4827
  const routeSection = routePattern.split("/").filter(Boolean)[0];
4752
- if (!shouldIncludeSection(routeSection, isSingleCollection, targetCollection)) {
4828
+ if (!shouldIncludeSection(routeSection, isScoped, targetCollection)) {
4753
4829
  return;
4754
4830
  }
4755
4831
  const filteredRoutes = routes.filter((r) => !shouldExcludeRoute(r.path, llmsConfig?.excludeRoutes));
@@ -4758,15 +4834,14 @@ function addSSRDataSection(parts, routePattern, routes, baseUrl, isSingleCollect
4758
4834
  const sectionName = routeSection?.charAt(0).toUpperCase() + routeSection?.slice(1) || "Content";
4759
4835
  parts.push(`## ${sectionName}`);
4760
4836
  parts.push("");
4837
+ const summaries = summariesEnabled(llmsConfig);
4761
4838
  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})`);
4839
+ parts.push(formatIndexLine(route, `${baseUrl}${route.path}.txt`, summaries));
4765
4840
  }
4766
4841
  parts.push("");
4767
4842
  }
4768
- function addStaticSection(parts, section, routes, baseUrl, isSingleCollection, targetCollection, collectionsMap, llmsConfig) {
4769
- if (!shouldIncludeSection(section, isSingleCollection, targetCollection)) {
4843
+ function addStaticSection(parts, section, routes, baseUrl, isScoped, targetCollection, collectionsMap, llmsConfig) {
4844
+ if (!shouldIncludeSection(section, isScoped, targetCollection)) {
4770
4845
  return;
4771
4846
  }
4772
4847
  const filteredRoutes = routes.filter((r) => !shouldExcludeRoute(r.path, llmsConfig?.excludeRoutes));
@@ -4775,24 +4850,23 @@ function addStaticSection(parts, section, routes, baseUrl, isSingleCollection, t
4775
4850
  const sectionName = section.charAt(0).toUpperCase() + section.slice(1);
4776
4851
  parts.push(`## ${sectionName}`);
4777
4852
  parts.push("");
4853
+ const summaries = summariesEnabled(llmsConfig);
4778
4854
  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})`);
4855
+ parts.push(formatIndexLine(route, `${baseUrl}${route.path}.txt`, summaries));
4782
4856
  }
4783
4857
  parts.push("");
4784
4858
  }
4785
4859
  async function generateLLMsIndex(options) {
4786
4860
  const { cwd, collections: collections2, baseUrl, isWatchMode, llmsConfig } = options;
4861
+ const targetCollection = options.targetCollection ?? null;
4862
+ const isScoped = targetCollection !== null;
4787
4863
  const parts = [];
4788
4864
  addIndexHeader(parts, llmsConfig);
4789
4865
  const staticRoutes = await discoverStaticRoutes(cwd, isWatchMode);
4790
4866
  const collectionsMap = await discoverCollectionRoutes(cwd, collections2, isWatchMode, llmsConfig);
4791
4867
  const ssrDataRoutes = await discoverSSRDataRoutes(cwd, staticRoutes, isWatchMode);
4792
- const isSingleCollection = collections2.length === 1;
4793
- const targetCollection = isSingleCollection ? collections2[0] : null;
4794
4868
  const { sections, rootRoutes } = groupStaticRoutes(staticRoutes, llmsConfig);
4795
- addRootRoutes(parts, rootRoutes, baseUrl, isSingleCollection);
4869
+ addRootRoutes(parts, rootRoutes, baseUrl, isScoped, llmsConfig);
4796
4870
  for (const [collection, routes] of collectionsMap.entries()) {
4797
4871
  if (routes.length > 0) {
4798
4872
  addCollectionSection(parts, collection, routes, baseUrl, llmsConfig);
@@ -4800,12 +4874,12 @@ async function generateLLMsIndex(options) {
4800
4874
  }
4801
4875
  for (const [routePattern, routes] of ssrDataRoutes.entries()) {
4802
4876
  if (routes.length > 0) {
4803
- addSSRDataSection(parts, routePattern, routes, baseUrl, isSingleCollection, targetCollection, llmsConfig);
4877
+ addSSRDataSection(parts, routePattern, routes, baseUrl, isScoped, targetCollection, llmsConfig);
4804
4878
  }
4805
4879
  }
4806
4880
  for (const [section, routes] of sections.entries()) {
4807
4881
  if (routes.length > 0) {
4808
- addStaticSection(parts, section, routes, baseUrl, isSingleCollection, targetCollection, collectionsMap, llmsConfig);
4882
+ addStaticSection(parts, section, routes, baseUrl, isScoped, targetCollection, collectionsMap, llmsConfig);
4809
4883
  }
4810
4884
  }
4811
4885
  parts.push("---");
@@ -4868,6 +4942,9 @@ async function discoverAllRoutes(cwd, collections2, isWatchMode, llmsConfig) {
4868
4942
  }
4869
4943
  return allRoutes;
4870
4944
  }
4945
+ function routeBelongsToCollection(path3, collection) {
4946
+ return path3 === `/${collection}` || path3.startsWith(`/${collection}/`);
4947
+ }
4871
4948
  function formatContentBlock(content, routePath, baseUrl) {
4872
4949
  const parts = [];
4873
4950
  const lines = content.split(`
@@ -4937,7 +5014,9 @@ function buildFooter(parts) {
4937
5014
  async function generateLLMsFullContent(options) {
4938
5015
  const { cwd, collections: collections2, baseUrl, isWatchMode, llmsConfig } = options;
4939
5016
  const parts = buildHeader(baseUrl, llmsConfig);
4940
- const allRoutes = await discoverAllRoutes(cwd, collections2, isWatchMode, llmsConfig);
5017
+ const discovered = await discoverAllRoutes(cwd, collections2, isWatchMode, llmsConfig);
5018
+ const targetCollection = options.targetCollection;
5019
+ const allRoutes = targetCollection ? discovered.filter((route) => routeBelongsToCollection(route.path, targetCollection)) : discovered;
4941
5020
  const maxItems = llmsConfig?.maxItems || 1e4;
4942
5021
  const routesToProcess = allRoutes.slice(0, maxItems);
4943
5022
  const extracted = await extractRouteContents(routesToProcess, options);
@@ -107077,7 +107156,7 @@ async function getVersionString2() {
107077
107156
  }
107078
107157
  async function getVersion2() {
107079
107158
  if (true) {
107080
- return "1.0.0-alpha.5";
107159
+ return "1.0.0-alpha.7";
107081
107160
  }
107082
107161
  const possiblePaths = [
107083
107162
  path3.join(import.meta.dir, "../../../package.json"),
@@ -107094,10 +107173,10 @@ async function getVersion2() {
107094
107173
  }
107095
107174
  async function getCommit2() {
107096
107175
  if (true) {
107097
- return "403cf32";
107176
+ return "19dcaf7";
107098
107177
  }
107099
107178
  return "dev";
107100
107179
  }
107101
107180
  main();
107102
107181
 
107103
- //# debugId=CD4585F819A6C03E64756E2164756E21
107182
+ //# debugId=958B942751A1FF3B64756E2164756E21