@publish.os/nextjs 0.0.1-alpha.90 → 0.0.1-alpha.92

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 (284) hide show
  1. package/compiler-assets/nextjs/defaults/group/index.tsx +16 -11
  2. package/compiler-assets/nextjs/defaults/group/layout.tsx +6 -6
  3. package/compiler-assets/nextjs/defaults/group/page.tsx +36 -26
  4. package/compiler-assets/nextjs/defaults/project/next.config.mjs +21 -11
  5. package/compiler-assets/nextjs/defaults/project/tsconfig.json.template +10 -0
  6. package/compiler-assets/nextjs/defaults/root/css/components/code-block.css +18 -0
  7. package/compiler-assets/nextjs/defaults/root/index.tsx +16 -11
  8. package/compiler-assets/nextjs/defaults/root/layout.tsx +7 -3
  9. package/compiler-assets/nextjs/shims/agent-user-agents.ts +65 -0
  10. package/compiler-assets/nextjs/shims/document.tsx +46 -0
  11. package/compiler-assets/nextjs/shims/generated-leaf-page.tsx +5 -0
  12. package/compiler-assets/nextjs/shims/global-layout.tsx +8 -42
  13. package/compiler-assets/nextjs/shims/global-not-found.tsx +69 -0
  14. package/compiler-assets/nextjs/shims/markdown-route.ts +2 -0
  15. package/compiler-assets/nextjs/shims/metadata-icons.tsx +39 -0
  16. package/compiler-assets/nextjs/shims/not-found-content.tsx +53 -0
  17. package/compiler-assets/nextjs/shims/not-found-navigation.tsx +60 -0
  18. package/compiler-assets/nextjs/shims/proxy.ts +254 -86
  19. package/compiler-assets/nextjs/shims/site-fenced-code-block.tsx +2 -6
  20. package/compiler-assets/nextjs/shims/site-mdx-components.tsx +28 -16
  21. package/compiler-assets/nextjs/shims/site-mdx.tsx +6 -1
  22. package/dist/{build-operation-2JAYBSKF.js → build-operation-CJDUL4OW.js} +29 -23
  23. package/dist/{button-c3WGnxIj.d.ts → button-D6Xp2HBm.d.ts} +4 -4
  24. package/dist/capture-local-source-WGGDIUU2.js +258 -0
  25. package/dist/chunk-22RSSUNV.js +13 -0
  26. package/dist/chunk-3T4HVDSC.js +426 -0
  27. package/dist/{chunk-WKTEO6RS.js → chunk-4BC2L2KA.js} +46 -12
  28. package/dist/{chunk-WDY4IK6Z.js → chunk-5J3YUNRY.js} +3 -10
  29. package/dist/chunk-5KAD7W53.js +248 -0
  30. package/dist/{chunk-DWA3ZRGW.js → chunk-6C65KV7O.js} +2 -2
  31. package/dist/{chunk-GGKFQ3MA.js → chunk-6D2E6UMD.js} +144 -70
  32. package/dist/{chunk-7OGTPSKI.js → chunk-7NY22B5U.js} +8 -3
  33. package/dist/chunk-DX7PXFCM.js +2519 -0
  34. package/dist/{chunk-726GV2NF.js → chunk-DZ3VWEV5.js} +950 -632
  35. package/dist/chunk-EFO6AWXN.js +19 -0
  36. package/dist/chunk-IL4RJOKI.js +186 -0
  37. package/dist/{chunk-H6XILMZX.js → chunk-NHSLTARU.js} +2588 -1493
  38. package/dist/{chunk-DLDFHU7Y.js → chunk-NNBJZPFM.js} +4 -2
  39. package/dist/{chunk-VO2I7MTM.js → chunk-SBMDONTV.js} +10 -7
  40. package/dist/{chunk-YLTOLYWM.js → chunk-WL75GQ5M.js} +6 -18
  41. package/dist/compiler.d.ts +15 -2
  42. package/dist/compiler.js +111 -23
  43. package/dist/components/blocks/agent-actions.d.ts +81 -0
  44. package/dist/components/blocks/agent-actions.js +563 -0
  45. package/dist/components/blocks/toc.d.ts +43 -0
  46. package/dist/components/blocks/toc.js +136 -0
  47. package/dist/components/ui/button.d.ts +4 -0
  48. package/dist/components/ui/button.js +94 -0
  49. package/dist/compose-44GJSMXD.js +16 -0
  50. package/dist/config/createNextConfig.js +19 -3
  51. package/dist/{dev-operation-TZDVJCN7.js → dev-operation-WNECBHZ5.js} +134 -84
  52. package/dist/{framework-selection-X4U6Y6QC.js → framework-selection-ZVO323PK.js} +3 -2
  53. package/dist/ide-support-TG74L4FF.js +16 -0
  54. package/dist/index.d.ts +151 -95
  55. package/dist/index.js +25 -0
  56. package/dist/jsx-dev-runtime.d.ts +6 -0
  57. package/dist/jsx-dev-runtime.js +100 -0
  58. package/dist/jsx-runtime.d.ts +7 -0
  59. package/dist/jsx-runtime.js +97 -0
  60. package/dist/kernel/components/blocks/AgentActions.d.ts +37 -8
  61. package/dist/kernel/components/blocks/AgentActions.js +384 -174
  62. package/dist/kernel/components/blocks/agent-actions.d.ts +4 -0
  63. package/dist/kernel/components/blocks/agent-actions.js +563 -0
  64. package/dist/kernel/components/blocks/animated-icon-swap.d.ts +2 -2
  65. package/dist/kernel/components/blocks/animated-icon-swap.js +1 -1
  66. package/dist/kernel/components/blocks/color-palette.d.ts +2 -2
  67. package/dist/kernel/components/blocks/color-palette.js +4 -4
  68. package/dist/kernel/components/blocks/logo-block.d.ts +2 -2
  69. package/dist/kernel/components/blocks/logo-block.js +1 -1
  70. package/dist/kernel/components/blocks/nav-breadcrumb.d.ts +6 -5
  71. package/dist/kernel/components/blocks/nav-breadcrumb.js +21 -15
  72. package/dist/kernel/components/blocks/navbar.d.ts +5 -4
  73. package/dist/kernel/components/blocks/navbar.js +79 -59
  74. package/dist/kernel/components/blocks/navigation-progress.d.ts +2 -2
  75. package/dist/kernel/components/blocks/navigation-progress.js +2 -2
  76. package/dist/kernel/components/blocks/next-prev.d.ts +4 -4
  77. package/dist/kernel/components/blocks/next-prev.js +30 -7
  78. package/dist/kernel/components/blocks/page-list.d.ts +4 -4
  79. package/dist/kernel/components/blocks/page-list.js +32 -9
  80. package/dist/kernel/components/blocks/search.d.ts +9 -15
  81. package/dist/kernel/components/blocks/search.js +16 -17
  82. package/dist/kernel/components/blocks/sidebar-node.d.ts +3 -5
  83. package/dist/kernel/components/blocks/sidebar-node.js +13 -3
  84. package/dist/kernel/components/blocks/sidebar.d.ts +6 -7
  85. package/dist/kernel/components/blocks/sidebar.js +137 -28
  86. package/dist/kernel/components/blocks/theme-toggle.d.ts +3 -4
  87. package/dist/kernel/components/blocks/theme-toggle.js +5 -5
  88. package/dist/kernel/components/blocks/toc-client.d.ts +40 -0
  89. package/dist/kernel/components/blocks/toc-client.js +495 -0
  90. package/dist/kernel/components/blocks/toc.d.ts +20 -2
  91. package/dist/kernel/components/blocks/toc.js +121 -179
  92. package/dist/kernel/components/mdx/components/blockquote.d.ts +2 -2
  93. package/dist/kernel/components/mdx/components/blockquote.js +1 -1
  94. package/dist/kernel/components/mdx/components/callout.d.ts +3 -3
  95. package/dist/kernel/components/mdx/components/callout.js +1 -1
  96. package/dist/kernel/components/mdx/components/code-block.d.ts +2 -2
  97. package/dist/kernel/components/mdx/components/code-block.js +2 -2
  98. package/dist/kernel/components/mdx/components/copy-code-button.d.ts +2 -2
  99. package/dist/kernel/components/mdx/components/copy-code-button.js +5 -4
  100. package/dist/kernel/components/mdx/components/figure-caption.d.ts +3 -3
  101. package/dist/kernel/components/mdx/components/figure-caption.js +3 -2
  102. package/dist/kernel/components/mdx/components/figure.d.ts +8 -4
  103. package/dist/kernel/components/mdx/components/figure.js +23 -13
  104. package/dist/kernel/components/mdx/components/footnotes.d.ts +2 -2
  105. package/dist/kernel/components/mdx/components/footnotes.js +1 -1
  106. package/dist/kernel/components/mdx/components/heading-copy-link.d.ts +2 -2
  107. package/dist/kernel/components/mdx/components/heading-copy-link.js +1 -1
  108. package/dist/kernel/components/mdx/components/heading.d.ts +2 -2
  109. package/dist/kernel/components/mdx/components/heading.js +6 -3
  110. package/dist/kernel/components/mdx/components/hr.d.ts +4 -4
  111. package/dist/kernel/components/mdx/components/hr.js +2 -2
  112. package/dist/kernel/components/mdx/components/image-zoom.d.ts +3 -3
  113. package/dist/kernel/components/mdx/components/image-zoom.js +4 -3
  114. package/dist/kernel/components/mdx/components/image.d.ts +2 -2
  115. package/dist/kernel/components/mdx/components/image.js +22 -17
  116. package/dist/kernel/components/mdx/components/inline-code.d.ts +2 -2
  117. package/dist/kernel/components/mdx/components/inline-code.js +1 -1
  118. package/dist/kernel/components/mdx/components/kbd.d.ts +3 -3
  119. package/dist/kernel/components/mdx/components/kbd.js +2 -2
  120. package/dist/kernel/components/mdx/components/link.d.ts +6 -6
  121. package/dist/kernel/components/mdx/components/link.js +2 -2
  122. package/dist/kernel/components/mdx/components/paragraph.d.ts +2 -2
  123. package/dist/kernel/components/mdx/components/paragraph.js +1 -1
  124. package/dist/kernel/components/mdx/components/strikethrough.d.ts +2 -2
  125. package/dist/kernel/components/mdx/components/strikethrough.js +1 -1
  126. package/dist/kernel/components/mdx/components/table.d.ts +7 -7
  127. package/dist/kernel/components/mdx/components/table.js +2 -2
  128. package/dist/kernel/components/mdx/components/task-list.d.ts +3 -3
  129. package/dist/kernel/components/mdx/components/task-list.js +1 -1
  130. package/dist/kernel/components/mdx/components/video-player.d.ts +8 -4
  131. package/dist/kernel/components/mdx/components/video-player.js +6 -2
  132. package/dist/kernel/components/mdx/components/video.d.ts +5 -4
  133. package/dist/kernel/components/mdx/components/video.js +7 -5
  134. package/dist/kernel/components/mdx/error-boundary.d.ts +3 -4
  135. package/dist/kernel/components/mdx/error-boundary.js +2 -2
  136. package/dist/kernel/components/mdx/error-fallback.d.ts +2 -2
  137. package/dist/kernel/components/mdx/error-fallback.js +1 -1
  138. package/dist/kernel/components/mdx/mdx.d.ts +57 -16
  139. package/dist/kernel/components/mdx/mdx.js +232 -35
  140. package/dist/kernel/components/mdx/rehype-heading-ids.d.ts +1 -0
  141. package/dist/kernel/components/mdx/rehype-heading-ids.js +5 -3
  142. package/dist/kernel/components/mdx/types.d.ts +1 -1
  143. package/dist/kernel/components/next-image.d.ts +12 -0
  144. package/dist/kernel/components/next-image.js +61 -0
  145. package/dist/kernel/components/ui/accordion.d.ts +7 -7
  146. package/dist/kernel/components/ui/accordion.js +1 -1
  147. package/dist/kernel/components/ui/breadcrumb-trail.d.ts +3 -4
  148. package/dist/kernel/components/ui/breadcrumb-trail.js +2 -2
  149. package/dist/kernel/components/ui/breadcrumb.d.ts +14 -14
  150. package/dist/kernel/components/ui/breadcrumb.js +4 -4
  151. package/dist/kernel/components/ui/button-group.d.ts +6 -6
  152. package/dist/kernel/components/ui/button-group.js +3 -3
  153. package/dist/kernel/components/ui/button.d.ts +59 -7
  154. package/dist/kernel/components/ui/button.js +43 -39
  155. package/dist/kernel/components/ui/card.d.ts +7 -7
  156. package/dist/kernel/components/ui/card.js +1 -1
  157. package/dist/kernel/components/ui/dialog.d.ts +10 -10
  158. package/dist/kernel/components/ui/dialog.js +1 -1
  159. package/dist/kernel/components/ui/drawer.d.ts +12 -12
  160. package/dist/kernel/components/ui/drawer.js +1 -1
  161. package/dist/kernel/components/ui/input.d.ts +2 -2
  162. package/dist/kernel/components/ui/input.js +1 -1
  163. package/dist/kernel/components/ui/kbd.d.ts +4 -4
  164. package/dist/kernel/components/ui/kbd.js +1 -1
  165. package/dist/kernel/components/ui/link.d.ts +11 -5
  166. package/dist/kernel/components/ui/link.js +2 -2
  167. package/dist/kernel/components/ui/menu.d.ts +22 -22
  168. package/dist/kernel/components/ui/menu.js +1 -1
  169. package/dist/kernel/components/ui/mod-key.d.ts +2 -3
  170. package/dist/kernel/components/ui/mod-key.js +2 -2
  171. package/dist/kernel/components/ui/navigation-menu.d.ts +15 -15
  172. package/dist/kernel/components/ui/navigation-menu.js +1 -1
  173. package/dist/kernel/components/ui/popover.d.ts +11 -11
  174. package/dist/kernel/components/ui/popover.js +1 -1
  175. package/dist/kernel/components/ui/progress.d.ts +7 -7
  176. package/dist/kernel/components/ui/progress.js +1 -1
  177. package/dist/kernel/components/ui/scroll-area.d.ts +9 -10
  178. package/dist/kernel/components/ui/scroll-area.js +1 -1
  179. package/dist/kernel/components/ui/select.d.ts +16 -16
  180. package/dist/kernel/components/ui/select.js +1 -1
  181. package/dist/kernel/components/ui/separator.d.ts +3 -3
  182. package/dist/kernel/components/ui/separator.js +1 -1
  183. package/dist/kernel/components/ui/table.d.ts +7 -7
  184. package/dist/kernel/components/ui/table.js +1 -1
  185. package/dist/kernel/components/ui/tabs.d.ts +12 -12
  186. package/dist/kernel/components/ui/tabs.js +1 -1
  187. package/dist/kernel/components/ui/tag.d.ts +3 -3
  188. package/dist/kernel/components/ui/tag.js +1 -1
  189. package/dist/kernel/components/ui/text.d.ts +4 -4
  190. package/dist/kernel/components/ui/text.js +1 -1
  191. package/dist/kernel/components/ui/toast.d.ts +11 -11
  192. package/dist/kernel/components/ui/toast.js +1 -1
  193. package/dist/kernel/components/ui/tooltip.d.ts +9 -9
  194. package/dist/kernel/components/ui/tooltip.js +1 -1
  195. package/dist/kernel/defaults.registry.d.ts +4 -17
  196. package/dist/kernel/defaults.registry.js +4 -19
  197. package/dist/kernel/routes/agent/markdown.d.ts +7 -0
  198. package/dist/kernel/routes/agent/markdown.js +229 -54
  199. package/dist/kernel/routes/layouts/group.d.ts +1 -1
  200. package/dist/kernel/routes/layouts/group.js +5 -7
  201. package/dist/kernel/routes/metadata/feed.d.ts +1 -2
  202. package/dist/kernel/routes/metadata/feed.js +119 -88
  203. package/dist/kernel/routes/metadata/llms.d.ts +3 -23
  204. package/dist/kernel/routes/metadata/llms.js +2 -103
  205. package/dist/kernel/routes/metadata/og-image.js +1 -1
  206. package/dist/kernel/routes/metadata/robots.d.ts +5 -3
  207. package/dist/kernel/routes/metadata/robots.js +4 -25
  208. package/dist/kernel/routes/metadata/sitemap.d.ts +36 -3
  209. package/dist/kernel/routes/metadata/sitemap.js +277 -49
  210. package/dist/kernel/routes/not-found.d.ts +34 -0
  211. package/dist/kernel/routes/not-found.js +213 -0
  212. package/dist/kernel/routes/pages/group.d.ts +5 -5
  213. package/dist/kernel/routes/pages/group.js +11 -5
  214. package/dist/kernel/routes/pages/leaf.d.ts +38 -6
  215. package/dist/kernel/routes/pages/leaf.js +21 -12
  216. package/dist/kernel/routes/pages/root.d.ts +5 -5
  217. package/dist/kernel/routes/pages/root.js +21 -6
  218. package/dist/keyboard-shortcuts.d.ts +2 -2
  219. package/dist/keyboard-shortcuts.js +1 -1
  220. package/dist/manifest-types-CcVPH_jh.d.ts +83 -0
  221. package/dist/resolvers/manifest-resolver.d.ts +2 -2
  222. package/dist/resolvers/manifest-resolver.js +65 -35
  223. package/dist/route-metadata-og-image-BeKKFHg7.d.ts +58 -0
  224. package/dist/search.d.ts +2 -9
  225. package/dist/search.js +9 -16
  226. package/dist/sidebar-types-CMrMM0Nj.d.ts +105 -0
  227. package/dist/theme-scope.d.ts +2 -2
  228. package/dist/theme-scope.js +1 -1
  229. package/dist/types-BbqmOzLC.d.ts +168 -0
  230. package/dist/types-TjH1ek0X.d.ts +22 -0
  231. package/dist/types-sM2g9nW0.d.ts +12 -0
  232. package/dist/types.d.ts +117 -91
  233. package/dist/utils/heading-ids.js +30 -11
  234. package/dist/utils/toc-selection.d.ts +7 -0
  235. package/dist/utils/toc-selection.js +14 -0
  236. package/dist/validate-local-source-EN2GW4FR.js +16 -0
  237. package/dist/validate-publish-os-source-OEWQDB7B.js +14 -0
  238. package/init/seed/minimal/publish.os/assets/blog/hello-world.svg +13 -0
  239. package/init/seed/minimal/publish.os/assets/favicon.dark.svg +13 -0
  240. package/init/seed/minimal/publish.os/assets/favicon.svg +13 -0
  241. package/init/seed/minimal/publish.os/blog/content/hello-world.mdx +48 -0
  242. package/init/seed/minimal/publish.os/blog/content/series-a.mdx +11 -0
  243. package/init/seed/minimal/publish.os/blog/index.tsx +85 -0
  244. package/init/seed/minimal/publish.os/blog/layout.tsx +13 -0
  245. package/init/seed/minimal/publish.os/blog/page.tsx +91 -0
  246. package/init/seed/minimal/publish.os/components/blog/copy-link.tsx +64 -0
  247. package/init/seed/minimal/publish.os/components/blog/frontmatter.ts +41 -0
  248. package/init/seed/minimal/publish.os/docs/content/get-started.mdx +2 -3
  249. package/init/seed/minimal/publish.os/docs/content/groups.mdx +5 -6
  250. package/init/seed/minimal/publish.os/publish.os.config.json +17 -2
  251. package/init/seed/minimal/publish.os/theme.css +3 -3
  252. package/init/seed/minimal/seed.json +12 -4
  253. package/init/seed/scratch/publish.os/docs/content/get-started.mdx +1 -1
  254. package/init/seed/scratch/publish.os/publish.os.config.json +1 -1
  255. package/package.json +48 -23
  256. package/release/app/phosphor/package.json +4 -4
  257. package/release/app/phosphor/pnpm-lock.yaml.template +123 -184
  258. package/release/compiler/package.json +5 -3
  259. package/release/compiler/pnpm-lock.yaml.template +153 -183
  260. package/release/release.json +6 -6
  261. package/dist/button-CtzUJB8u.d.ts +0 -11
  262. package/dist/chunk-535TM4A5.js +0 -1455
  263. package/dist/chunk-B2V22WRT.js +0 -297
  264. package/dist/chunk-NECL5IBJ.js +0 -318
  265. package/dist/chunk-SVYGXXYR.js +0 -36
  266. package/dist/chunk-UF6ATARM.js +0 -1100
  267. package/dist/compose-NN23UJGC.js +0 -13
  268. package/dist/ide-support-ZNW7ODFY.js +0 -15
  269. package/dist/kernel/components/blocks/design-system-preview.d.ts +0 -61
  270. package/dist/kernel/components/blocks/design-system-preview.js +0 -667
  271. package/dist/kernel/components/blocks/link-playground.d.ts +0 -5
  272. package/dist/kernel/components/blocks/link-playground.js +0 -744
  273. package/dist/kernel/components/blocks/navigation-progress-playground.d.ts +0 -5
  274. package/dist/kernel/components/blocks/navigation-progress-playground.js +0 -629
  275. package/dist/kernel/components/ui/theme-toggle.d.ts +0 -24
  276. package/dist/kernel/components/ui/theme-toggle.js +0 -53
  277. package/dist/sidebar-types-DKpR27II.d.ts +0 -25
  278. package/dist/types-BzkZty3r.d.ts +0 -147
  279. package/dist/types-CJWRG05y.d.ts +0 -76
  280. package/dist/types-CUtrppxt.d.ts +0 -69
  281. package/dist/validate-local-source-XRL2Y7XE.js +0 -14
  282. package/dist/validate-publish-os-source-DAPZ4QGE.js +0 -12
  283. package/init/seed/minimal/publish.os/assets/favicon/favicon.dark.png +0 -0
  284. package/init/seed/minimal/publish.os/assets/favicon/favicon.png +0 -0
@@ -1,18 +1,3 @@
1
- // src/route-metadata-llms.ts
2
- import { tags } from "@publish.os/nextjs/cache/tags";
3
- import { cacheLife, cacheTag } from "next/cache";
4
-
5
- // src/lib/runtime/metadata/canonical-url.ts
6
- function canonicalUrl(manifest, path, group) {
7
- let origin = (group && manifest.groups[group]?.origin) ?? manifest.site.origin;
8
- if (!origin) return path;
9
- try {
10
- return new URL(path, `${origin}/`).toString();
11
- } catch {
12
- return path;
13
- }
14
- }
15
-
16
1
  // src/lib/runtime/response/cached-text-response.ts
17
2
  var CACHE_CONTROL = "public, max-age=300, s-maxage=3600, stale-while-revalidate=3600, must-revalidate", CDN_CACHE_CONTROL = "public, max-age=3600, stale-while-revalidate=3600, must-revalidate", SHORT_CACHE_CONTROL = "public, max-age=60, s-maxage=600, stale-while-revalidate=300, must-revalidate", SHORT_CDN_CACHE_CONTROL = "public, max-age=300, stale-while-revalidate=3600";
18
3
  function cacheControl(policy) {
@@ -34,53 +19,7 @@ function createCachedTextResponse(options) {
34
19
  }
35
20
 
36
21
  // src/route-metadata-llms.ts
37
- var DEFAULT_LLMS_FULL_MAX_BYTES = 1e6, TEXT_ENCODER = new TextEncoder();
38
- function byteLength(value) {
39
- return TEXT_ENCODER.encode(value).byteLength;
40
- }
41
- function pageInScope(page, options) {
42
- return options.scope === "site" || !options.group ? !0 : options.scope === "self" ? page.group === options.group : page.group === options.group || page.group.startsWith(`${options.group}/`);
43
- }
44
- function llmsSummary(manifest) {
45
- return manifest.site.description ? `> ${manifest.site.description}` : `> Agent-readable index for ${manifest.site.name}.`;
46
- }
47
- async function llmsTxt(manifest, options = {}) {
48
- "use cache";
49
- cacheLife("page"), cacheTag(
50
- tags.site(),
51
- tags.llms(options.group ?? options.scope ?? "root"),
52
- tags.manifest(manifest.contentHash)
53
- );
54
- let pages = manifest.pages.filter((page) => page.status === "published").filter((page) => pageInScope(page, options)), lines = (options.limit ? pages.slice(0, options.limit) : pages).map((page) => {
55
- let description = options.includeDescriptions && page.description ? ` - ${page.description}` : "";
56
- return `- [${page.title}](${canonicalUrl(manifest, page.path, page.group)})${description}`;
57
- }), linkLines = (options.links ?? []).map(
58
- (link) => `- [${link.title}](${canonicalUrl(manifest, link.path, link.group)})`
59
- ), linkSection = linkLines.length ? `
60
-
61
- ## Group LLM indexes
62
-
63
- ${linkLines.join(`
64
- `)}` : "";
65
- return `# ${manifest.site.name}
66
-
67
- ${llmsSummary(manifest)}
68
-
69
- ## Pages
70
-
71
- ${lines.join(`
72
- `)}${linkSection}
73
- `;
74
- }
75
- function createLlmsTxtRoute(manifest, options = {}) {
76
- return async function() {
77
- return createCachedTextResponse({
78
- body: await llmsTxt(manifest, options),
79
- contentType: "text/plain; charset=utf-8"
80
- });
81
- };
82
- }
83
- function createPrecomputedLlmsTxtRoute(output) {
22
+ function createLlmsTxtRoute(output) {
84
23
  return function() {
85
24
  return createCachedTextResponse({
86
25
  body: output.body,
@@ -88,46 +27,6 @@ function createPrecomputedLlmsTxtRoute(output) {
88
27
  });
89
28
  };
90
29
  }
91
- async function llmsFullTxt(manifest, artifacts, options = {}) {
92
- let maxBytes = options.maxBytes ?? DEFAULT_LLMS_FULL_MAX_BYTES, header = `# ${manifest.site.name} Full Content
93
-
94
- > LLMS index: ${canonicalUrl(manifest, "/llms.txt")}
95
- > Sitemap: ${canonicalUrl(manifest, "/sitemap.md")}
96
-
97
- `, sections = [], totalBytes = byteLength(header), included = 0, truncated = !1;
98
- for (let artifact of Object.values(artifacts).sort(
99
- (a, b) => a.markdownPath.localeCompare(b.markdownPath)
100
- )) {
101
- let section = `---
102
-
103
- ${artifact.body.trim()}
104
-
105
- `, sectionBytes = byteLength(section);
106
- if (totalBytes + sectionBytes > maxBytes) {
107
- truncated = !0;
108
- break;
109
- }
110
- sections.push(section), totalBytes += sectionBytes, included += 1;
111
- }
112
- let footer = truncated ? `
113
- > Truncated at ${included} of ${Object.keys(artifacts).length} Markdown pages to stay under ${maxBytes} bytes.
114
- ` : "";
115
- return `${header}${sections.join("")}${footer}`;
116
- }
117
- async function llmsFullTxtResponse(manifest, artifacts, options = {}) {
118
- return createCachedTextResponse({
119
- body: await llmsFullTxt(manifest, artifacts, options),
120
- contentType: "text/plain; charset=utf-8"
121
- });
122
- }
123
- function createLlmsFullTxtRoute(manifest, artifacts, options = {}) {
124
- return async function() {
125
- return llmsFullTxtResponse(manifest, artifacts, options);
126
- };
127
- }
128
30
  export {
129
- createLlmsFullTxtRoute,
130
- createLlmsTxtRoute,
131
- createPrecomputedLlmsTxtRoute,
132
- llmsFullTxtResponse
31
+ createLlmsTxtRoute
133
32
  };
@@ -116,7 +116,7 @@ function getOgImageText(entry) {
116
116
  }
117
117
 
118
118
  // src/route-metadata-og-image.tsx
119
- import { jsx, jsxs } from "react/jsx-runtime";
119
+ import { jsx, jsxs } from "@publish.os/nextjs/jsx-runtime";
120
120
  var ERROR_HEADERS = {
121
121
  "cache-control": "public, max-age=60, must-revalidate",
122
122
  "cdn-cache-control": "public, max-age=300",
@@ -1,5 +1,7 @@
1
- import { M as ManifestLike } from '../../../types-BzkZty3r.js';
2
-
3
- declare function createRobotsTxtRoute(manifest: ManifestLike): () => Promise<Response>;
1
+ declare function createRobotsTxtRoute(defaultOutput: {
2
+ body: string;
3
+ }, outputsByOrigin?: Record<string, {
4
+ body: string;
5
+ }>): (request: Request) => Response;
4
6
 
5
7
  export { createRobotsTxtRoute };
@@ -1,18 +1,3 @@
1
- // src/route-metadata-robots.ts
2
- import { tags } from "@publish.os/nextjs/cache/tags";
3
- import { cacheLife, cacheTag } from "next/cache";
4
-
5
- // src/lib/runtime/metadata/canonical-url.ts
6
- function canonicalUrl(manifest, path, group) {
7
- let origin = (group && manifest.groups[group]?.origin) ?? manifest.site.origin;
8
- if (!origin) return path;
9
- try {
10
- return new URL(path, `${origin}/`).toString();
11
- } catch {
12
- return path;
13
- }
14
- }
15
-
16
1
  // src/lib/runtime/response/cached-text-response.ts
17
2
  var CACHE_CONTROL = "public, max-age=300, s-maxage=3600, stale-while-revalidate=3600, must-revalidate", CDN_CACHE_CONTROL = "public, max-age=3600, stale-while-revalidate=3600, must-revalidate", SHORT_CACHE_CONTROL = "public, max-age=60, s-maxage=600, stale-while-revalidate=300, must-revalidate", SHORT_CDN_CACHE_CONTROL = "public, max-age=300, stale-while-revalidate=3600";
18
3
  function cacheControl(policy) {
@@ -34,17 +19,11 @@ function createCachedTextResponse(options) {
34
19
  }
35
20
 
36
21
  // src/route-metadata-robots.ts
37
- async function robotsTxt(manifest) {
38
- "use cache";
39
- return cacheLife("page"), cacheTag(tags.site(), tags.robots(), tags.manifest(manifest.contentHash)), `User-agent: *
40
- Allow: /
41
- Sitemap: ${canonicalUrl(manifest, "/sitemap.xml")}
42
- `;
43
- }
44
- function createRobotsTxtRoute(manifest) {
45
- return async function() {
22
+ function createRobotsTxtRoute(defaultOutput, outputsByOrigin = {}) {
23
+ return function(request) {
24
+ let output = outputsByOrigin[new URL(request.url).origin] ?? defaultOutput;
46
25
  return createCachedTextResponse({
47
- body: await robotsTxt(manifest),
26
+ body: output.body,
48
27
  contentType: "text/plain; charset=utf-8"
49
28
  });
50
29
  };
@@ -1,10 +1,43 @@
1
1
  import { MarkdownRouteArtifactManifest } from '../agent/markdown.js';
2
- import { M as ManifestLike } from '../../../types-BzkZty3r.js';
2
+ import { M as ManifestLike } from '../../../types-BbqmOzLC.js';
3
+ import '../not-found.js';
3
4
 
5
+ type SitemapReference = {
6
+ path: string;
7
+ group?: string;
8
+ };
4
9
  type SitemapRouteOptions = {
5
10
  group?: string;
11
+ path?: string;
12
+ includeUrls?: SitemapReference[];
13
+ sitemaps?: SitemapReference[];
14
+ exclude?: SitemapReference[];
15
+ };
16
+ type SitemapMarkdownRouteOptions = {
17
+ group?: string;
18
+ path?: string;
19
+ scope?: "site" | "group" | "self";
20
+ excludeGroups?: string[];
21
+ includeUrls?: Array<{
22
+ path?: string;
23
+ group?: string;
24
+ url?: string;
25
+ }>;
26
+ groupSitemaps?: Array<SitemapReference & {
27
+ title: string;
28
+ }>;
29
+ parts?: Array<SitemapReference & {
30
+ title: string;
31
+ }>;
32
+ links?: Array<SitemapReference & {
33
+ title: string;
34
+ }>;
35
+ otherGroupLinks?: Array<SitemapReference & {
36
+ title: string;
37
+ }>;
38
+ markdownAlternates?: boolean;
6
39
  };
7
40
  declare function createSitemapXmlRoute(manifest: ManifestLike, options?: SitemapRouteOptions): () => Promise<Response>;
8
- declare function createSitemapMarkdownRoute(manifest: ManifestLike, artifactManifest: MarkdownRouteArtifactManifest): () => Promise<Response>;
41
+ declare function createSitemapMarkdownRoute(manifest: ManifestLike, artifactManifest: MarkdownRouteArtifactManifest, options?: SitemapMarkdownRouteOptions): () => Promise<Response>;
9
42
 
10
- export { type SitemapRouteOptions, createSitemapMarkdownRoute, createSitemapXmlRoute };
43
+ export { type SitemapMarkdownRouteOptions, type SitemapRouteOptions, createSitemapMarkdownRoute, createSitemapXmlRoute };
@@ -5,7 +5,8 @@ import { cacheLife, cacheTag } from "next/cache";
5
5
  // src/lib/runtime/metadata/canonical-url.ts
6
6
  function canonicalUrl(manifest, path, group) {
7
7
  let origin = (group && manifest.groups[group]?.origin) ?? manifest.site.origin;
8
- if (!origin) return path;
8
+ if (!origin)
9
+ return /^[a-z][a-z\d+.-]*:/i.test(path) ? path : new URL(path, "https://publish.invalid").pathname;
9
10
  try {
10
11
  return new URL(path, `${origin}/`).toString();
11
12
  } catch {
@@ -13,6 +14,111 @@ function canonicalUrl(manifest, path, group) {
13
14
  }
14
15
  }
15
16
 
17
+ // src/lib/runtime/metadata/discovery-content.ts
18
+ function discoveryOrigin(manifest, group) {
19
+ return (group ? manifest.groups[group]?.origin : void 0) ?? manifest.site.origin;
20
+ }
21
+ function navigationDiscoverySections({
22
+ manifest,
23
+ group,
24
+ scope,
25
+ limit,
26
+ excludeGroups = [],
27
+ markdownPaths
28
+ }) {
29
+ let origin = discoveryOrigin(manifest, group), targetGroup = group ? manifest.groups[group] : void 0, mountedGroup = Object.values(manifest.groups).find(
30
+ (candidate) => candidate.key !== "__root" && candidate.path === "/" && discoveryOrigin(manifest, candidate.key) === origin
31
+ ), rootGroups = targetGroup && scope !== "site" ? [manifest.groups[targetGroup.navigation.rootGroup]] : Object.values(manifest.groups).filter(
32
+ (candidate) => candidate.key === candidate.navigation.rootGroup && (candidate.key !== "__root" || !mountedGroup) && discoveryOrigin(manifest, candidate.key) === origin
33
+ ), sections = [], pageKeys = /* @__PURE__ */ new Set(), pageCount = 0, inScope = (entryGroup) => discoveryOrigin(manifest, entryGroup) !== origin || excludeGroups.some(
34
+ (excluded) => entryGroup === excluded || entryGroup.startsWith(`${excluded}/`)
35
+ ) ? !1 : !targetGroup || scope === "site" ? !0 : entryGroup === targetGroup.key || scope !== "self" && entryGroup.startsWith(`${targetGroup.key}/`), append = (title, entry) => {
36
+ let previous = sections.at(-1);
37
+ previous?.title === title ? previous.entries.push(entry) : sections.push({ title, entries: [entry] });
38
+ }, visit = (nodes, groupKey, headings) => {
39
+ for (let node of nodes)
40
+ if (node.type === "page") {
41
+ let page = node.page, key = `${page.group}/${page.fileID}`;
42
+ if (page.frontmatter.status !== "published" || !inScope(page.group) || pageKeys.has(key) || limit !== void 0 && limit > 0 && pageCount >= limit)
43
+ continue;
44
+ pageKeys.add(key), pageCount += 1, append(headings.join(" > "), {
45
+ type: "page",
46
+ title: node.label || page.frontmatter.title,
47
+ url: canonicalUrl(
48
+ manifest,
49
+ markdownPaths?.get(page.path) ?? page.path,
50
+ page.group
51
+ ),
52
+ path: page.path,
53
+ group: page.group,
54
+ ...page.frontmatter.description ? { description: page.frontmatter.description } : {}
55
+ }), node.children && visit(node.children, page.group, headings);
56
+ } else node.type === "group" ? (inScope(node.groupKey) && append(headings.join(" > "), {
57
+ type: "link",
58
+ title: node.label,
59
+ url: canonicalUrl(manifest, node.route, node.groupKey),
60
+ group: node.groupKey
61
+ }), visit(node.children, node.groupKey, [...headings, node.label])) : node.type === "link" ? inScope(groupKey) && append(headings.join(" > "), {
62
+ type: "link",
63
+ title: node.label,
64
+ url: canonicalUrl(manifest, node.href, groupKey),
65
+ group: groupKey
66
+ }) : node.type === "section" || node.type === "folder" ? visit(node.children, groupKey, [...headings, node.label]) : node.type === "view" && visit(node.items, groupKey, headings);
67
+ };
68
+ for (let root of rootGroups)
69
+ !root || discoveryOrigin(manifest, root.key) !== origin || (!targetGroup || scope === "site" ? append(root.title, {
70
+ type: "link",
71
+ title: root.title,
72
+ url: canonicalUrl(manifest, root.path, root.key),
73
+ group: root.key
74
+ }) : root.key === targetGroup.key && append(root.title, {
75
+ type: "link",
76
+ title: root.title,
77
+ url: canonicalUrl(manifest, root.path, root.key),
78
+ group: root.key
79
+ }), visit(root.navigation.items, root.key, [root.title]));
80
+ return sections;
81
+ }
82
+
83
+ // src/lib/runtime/metadata/llms-serialization.ts
84
+ function inlineText(value) {
85
+ return value.replace(/[\r\n]+/g, " ").replace(/([\\`*_[\]<>])/g, "\\$1");
86
+ }
87
+ function markdownLink(link) {
88
+ let url = link.url.replace(
89
+ /[\s()<>]/g,
90
+ (value) => value === "(" ? "%28" : value === ")" ? "%29" : encodeURIComponent(value)
91
+ );
92
+ return `[${inlineText(link.title)}](${url})`;
93
+ }
94
+ function serializeLlmsIndex(input) {
95
+ let body = (input.sections ?? []).map((section) => {
96
+ let lines = section.entries.map((entry) => {
97
+ let description = input.includeDescriptions && entry.description ? `: ${inlineText(entry.description)}` : "", alternate = entry.alternate ? ` (${markdownLink(entry.alternate)})` : "";
98
+ return `- ${markdownLink(entry)}${alternate}${description}`;
99
+ });
100
+ return `## ${inlineText(section.title)}
101
+
102
+ ${lines.join(`
103
+ `)}`;
104
+ }).join(`
105
+
106
+ `), otherGroupLines = (input.otherGroupLinks ?? []).map(
107
+ (link) => `- ${markdownLink(link)}`
108
+ ), otherGroupSection = otherGroupLines.length ? `
109
+
110
+ ## Other content groups
111
+
112
+ ${otherGroupLines.join(`
113
+ `)}` : "";
114
+ return `# ${inlineText(input.title)}
115
+
116
+ > ${inlineText(input.summary)}
117
+
118
+ ${body}${otherGroupSection}
119
+ `;
120
+ }
121
+
16
122
  // src/lib/runtime/response/cached-text-response.ts
17
123
  var CACHE_CONTROL = "public, max-age=300, s-maxage=3600, stale-while-revalidate=3600, must-revalidate", CDN_CACHE_CONTROL = "public, max-age=3600, stale-while-revalidate=3600, must-revalidate", SHORT_CACHE_CONTROL = "public, max-age=60, s-maxage=600, stale-while-revalidate=300, must-revalidate", SHORT_CDN_CACHE_CONTROL = "public, max-age=300, stale-while-revalidate=3600";
18
124
  function cacheControl(policy) {
@@ -35,44 +141,94 @@ function createCachedTextResponse(options) {
35
141
 
36
142
  // src/route-metadata-sitemap.ts
37
143
  var ROOT_CONTENT_GROUP_KEY = "__root";
144
+ function assertSitemapSize(options) {
145
+ let bytes = new TextEncoder().encode(options.body).byteLength;
146
+ if (options.entryCount > 5e4 || bytes > 52428800)
147
+ throw new RangeError(
148
+ `Generated sitemap "${options.path}" exceeds ${5e4} entries or ${52428800} UTF-8 bytes. Split or limit its content.`
149
+ );
150
+ return options.body;
151
+ }
38
152
  function xmlEscape(value) {
39
- return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
153
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/'/g, "&apos;").replace(/"/g, "&quot;");
40
154
  }
41
- function groupOrigin(manifest, groupKey) {
42
- return manifest.groups[groupKey]?.origin ?? manifest.site.origin;
155
+ function sitemapDirectory(path) {
156
+ return path.slice(0, path.lastIndexOf("/") + 1) || "/";
43
157
  }
44
- function pathInScope(path, basePath) {
45
- return basePath === "/" || path === basePath || path.startsWith(`${basePath}/`);
158
+ function isWithinDirectory(path, directories) {
159
+ for (let end = path.indexOf("/"); end >= 0; end = path.indexOf("/", end + 1))
160
+ if (directories.has(path.slice(0, end + 1))) return !0;
161
+ return !1;
46
162
  }
47
163
  function rootMountedGroup(manifest, origin) {
48
164
  return Object.values(manifest.groups).find(
49
- (group) => group.key !== ROOT_CONTENT_GROUP_KEY && group.path === "/" && groupOrigin(manifest, group.key) === origin
165
+ (group) => group.key !== ROOT_CONTENT_GROUP_KEY && group.path === "/" && discoveryOrigin(manifest, group.key) === origin
50
166
  );
51
167
  }
52
168
  async function sitemapXml(manifest, options) {
53
169
  "use cache";
54
170
  cacheLife("page"), cacheTag(tags.site(), tags.sitemap(), tags.manifest(manifest.contentHash));
55
- let targetGroup = options.group ? manifest.groups[options.group] : void 0, basePath = targetGroup?.path ?? "/", origin = targetGroup ? groupOrigin(manifest, targetGroup.key) : manifest.site.origin, homeGroup = targetGroup ?? rootMountedGroup(manifest, origin), groups = Object.values(manifest.groups).filter(
56
- (group) => groupOrigin(manifest, group.key) === origin && pathInScope(group.path, basePath)
171
+ let targetGroup = options.group ? manifest.groups[options.group] : void 0, directory = sitemapDirectory(
172
+ options.path ?? `${targetGroup?.path === "/" ? "" : targetGroup?.path ?? ""}/sitemap.xml`
173
+ ), origin = targetGroup ? discoveryOrigin(manifest, targetGroup.key) : manifest.site.origin, includedUrls = options.includeUrls ? new Set(
174
+ options.includeUrls.map(
175
+ ({ path, group }) => JSON.stringify([group ?? null, path])
176
+ )
177
+ ) : void 0, excludedDirectories = new Set(
178
+ (options.exclude ?? []).filter((sitemap) => discoveryOrigin(manifest, sitemap.group) === origin).map((sitemap) => sitemapDirectory(sitemap.path))
179
+ );
180
+ if (options.sitemaps) {
181
+ let urls2 = [
182
+ ...new Set(
183
+ options.sitemaps.filter(
184
+ (sitemap) => discoveryOrigin(manifest, sitemap.group) === origin
185
+ ).filter(
186
+ (sitemap) => sitemap.path.startsWith(directory) && sitemap.path !== options.path
187
+ ).map(
188
+ (sitemap) => canonicalUrl(manifest, sitemap.path, sitemap.group)
189
+ )
190
+ )
191
+ ], body2 = urls2.map((url) => ` <sitemap><loc>${xmlEscape(url)}</loc></sitemap>`).join(`
192
+ `);
193
+ return assertSitemapSize({
194
+ path: options.path ?? "/sitemap.xml",
195
+ entryCount: urls2.length,
196
+ body: `<?xml version="1.0" encoding="UTF-8"?>
197
+ <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
198
+ ${body2}
199
+ </sitemapindex>
200
+ `
201
+ });
202
+ }
203
+ let homeGroup = targetGroup ?? rootMountedGroup(manifest, origin), groups = Object.values(manifest.groups).filter(
204
+ (group) => discoveryOrigin(manifest, group.key) === origin && (directory === "/" || group.path.startsWith(directory))
57
205
  ), urls = [
58
206
  {
59
207
  path: homeGroup?.path ?? "/",
60
208
  group: homeGroup?.key
61
209
  },
62
210
  ...groups.map((group) => ({ path: group.path, group: group.key })),
63
- ...manifest.pages.filter((page) => page.status === "published").filter((page) => groupOrigin(manifest, page.group) === origin).filter((page) => pathInScope(page.path, basePath)).map((page) => ({ path: page.path, group: page.group }))
64
- ];
65
- return `<?xml version="1.0" encoding="UTF-8"?>
66
- <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
67
- ${[...new Map(
211
+ ...manifest.pages.filter(
212
+ (page) => page.frontmatter.status === "published" && page.frontmatter.metadata.robots?.index !== !1
213
+ ).filter((page) => discoveryOrigin(manifest, page.group) === origin).map((page) => ({ path: page.path, group: page.group }))
214
+ ].filter(
215
+ ({ path, group }) => (directory === "/" || path.startsWith(directory)) && (!includedUrls || includedUrls.has(JSON.stringify([group ?? null, path]))) && !isWithinDirectory(path, excludedDirectories)
216
+ ), uniqueUrls = new Map(
68
217
  urls.map(({ path, group }) => {
69
218
  let url = canonicalUrl(manifest, path, group);
70
219
  return [url, url];
71
220
  })
72
- ).values()].map((url) => ` <url><loc>${xmlEscape(url)}</loc></url>`).join(`
73
- `)}
221
+ ), body = [...uniqueUrls.values()].map((url) => ` <url><loc>${xmlEscape(url)}</loc></url>`).join(`
222
+ `);
223
+ return assertSitemapSize({
224
+ path: options.path ?? "/sitemap.xml",
225
+ entryCount: uniqueUrls.size,
226
+ body: `<?xml version="1.0" encoding="UTF-8"?>
227
+ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
228
+ ${body}
74
229
  </urlset>
75
- `;
230
+ `
231
+ });
76
232
  }
77
233
  function createSitemapXmlRoute(manifest, options = {}) {
78
234
  return async function() {
@@ -82,42 +238,114 @@ function createSitemapXmlRoute(manifest, options = {}) {
82
238
  });
83
239
  };
84
240
  }
85
- async function sitemapMarkdown(manifest, artifactManifest) {
86
- let origin = manifest.site.origin, rootGroup = rootMountedGroup(manifest, origin), groups = Object.values(manifest.groups).filter((group) => group.key !== ROOT_CONTENT_GROUP_KEY).filter((group) => groupOrigin(manifest, group.key) === origin).sort((a, b) => a.path.localeCompare(b.path)).map(
87
- (group) => `- [${group.title}](${canonicalUrl(manifest, group.path, group.key)})`
88
- ), pages = manifest.pages.filter((page) => page.status === "published").filter((page) => groupOrigin(manifest, page.group) === origin).sort((a, b) => a.path.localeCompare(b.path)).map((page) => {
89
- let markdownPath = artifactManifest.byHtmlPath[page.path], markdown = markdownPath ? ` ([Markdown](${canonicalUrl(manifest, markdownPath, page.group)}))` : "";
90
- return `- [${page.title}](${canonicalUrl(manifest, page.path, page.group)})${markdown}`;
241
+ async function sitemapMarkdown(manifest, artifactManifest, options) {
242
+ let origin = discoveryOrigin(manifest, options.group), targetGroup = options.group ? manifest.groups[options.group] : void 0, rootGroup = targetGroup?.key === ROOT_CONTENT_GROUP_KEY ? void 0 : targetGroup ?? rootMountedGroup(manifest, origin), markdownPaths = new Map(
243
+ options.markdownAlternates === !1 ? [] : Object.entries(artifactManifest.byHtmlPath)
244
+ ), linkedParts = options.parts ?? [], groupSitemaps = options.groupSitemaps ?? [], discoverySections = linkedParts.length ? [] : navigationDiscoverySections({
245
+ manifest,
246
+ ...options,
247
+ markdownPaths
248
+ }), selectors = options.includeUrls, remainingSelectors = /* @__PURE__ */ new Map(), selectorKeys = /* @__PURE__ */ new Map();
249
+ for (let [index, selector] of (selectors ?? []).entries()) {
250
+ let keys = /* @__PURE__ */ new Set();
251
+ selector.path !== void 0 && (keys.add(
252
+ `page:${JSON.stringify([selector.group ?? null, selector.path])}`
253
+ ), keys.add(
254
+ `url:${JSON.stringify([
255
+ selector.group ?? null,
256
+ canonicalUrl(manifest, selector.path, selector.group)
257
+ ])}`
258
+ )), selector.url !== void 0 && keys.add(`url:${JSON.stringify([selector.group ?? null, selector.url])}`), selectorKeys.set(index, [...keys]);
259
+ for (let key of keys) {
260
+ let candidates = remainingSelectors.get(key) ?? /* @__PURE__ */ new Set();
261
+ candidates.add(index), remainingSelectors.set(key, candidates);
262
+ }
263
+ }
264
+ let selectedSections = discoverySections.map((section) => ({
265
+ ...section,
266
+ entries: section.entries.filter((entry) => {
267
+ if (!selectors) return !0;
268
+ let key = entry.type === "page" ? `page:${JSON.stringify([entry.group ?? null, entry.path])}` : `url:${JSON.stringify([entry.group ?? null, entry.url])}`, selectorIndex = remainingSelectors.get(key)?.values().next().value;
269
+ if (selectorIndex === void 0) return !1;
270
+ for (let selectorKey of selectorKeys.get(selectorIndex) ?? []) {
271
+ let selectorCandidates = remainingSelectors.get(selectorKey);
272
+ selectorCandidates?.delete(selectorIndex), selectorCandidates?.size === 0 && remainingSelectors.delete(selectorKey);
273
+ }
274
+ return !0;
275
+ })
276
+ })).filter((section) => section.entries.length > 0), links = options.links ?? [
277
+ { title: "LLMS index", path: "/llms.txt" },
278
+ { title: "Full LLMS index", path: "/llms-full.txt" },
279
+ { title: "XML sitemap", path: "/sitemap.xml" }
280
+ ], body = serializeLlmsIndex({
281
+ title: `${rootGroup?.title ?? manifest.site.name} Sitemap`,
282
+ summary: "Browse the published pages and their available Markdown versions.",
283
+ sections: [
284
+ ...groupSitemaps.length ? [
285
+ {
286
+ title: "Content groups",
287
+ entries: groupSitemaps.map((sitemap) => ({
288
+ title: sitemap.title,
289
+ url: canonicalUrl(manifest, sitemap.path, sitemap.group)
290
+ }))
291
+ }
292
+ ] : [],
293
+ ...linkedParts.length ? [
294
+ {
295
+ title: "Parts",
296
+ entries: linkedParts.map((part) => ({
297
+ title: part.title,
298
+ url: canonicalUrl(manifest, part.path, part.group)
299
+ }))
300
+ }
301
+ ] : [],
302
+ ...links.length ? [
303
+ {
304
+ title: "Agent indexes",
305
+ entries: links.map((link) => ({
306
+ title: link.title,
307
+ url: canonicalUrl(manifest, link.path, link.group)
308
+ }))
309
+ }
310
+ ] : [],
311
+ ...selectedSections.map((section) => ({
312
+ title: section.title,
313
+ entries: section.entries.map((entry) => {
314
+ if (entry.type === "link") return entry;
315
+ let markdownPath = markdownPaths.get(entry.path);
316
+ return {
317
+ title: entry.title,
318
+ url: canonicalUrl(manifest, entry.path, entry.group),
319
+ ...markdownPath ? {
320
+ alternate: {
321
+ title: "Markdown",
322
+ url: canonicalUrl(manifest, markdownPath, entry.group)
323
+ }
324
+ } : {}
325
+ };
326
+ })
327
+ })),
328
+ ...options.otherGroupLinks?.length ? [
329
+ {
330
+ title: "Other content groups",
331
+ entries: options.otherGroupLinks.map((link) => ({
332
+ title: link.title,
333
+ url: canonicalUrl(manifest, link.path, link.group)
334
+ }))
335
+ }
336
+ ] : []
337
+ ]
338
+ });
339
+ return assertSitemapSize({
340
+ path: options.path ?? (options.group ? `${manifest.groups[options.group]?.path ?? ""}/sitemap.md` : "/sitemap.md"),
341
+ entryCount: (body.match(/\]\(/g) ?? []).length,
342
+ body
91
343
  });
92
- return [
93
- `# ${rootGroup?.title ?? manifest.site.name} Sitemap`,
94
- "## Agent indexes",
95
- `- [LLMS index](${canonicalUrl(manifest, "/llms.txt")})`,
96
- `- [Full LLMS index](${canonicalUrl(manifest, "/llms-full.txt")})`,
97
- `- [XML sitemap](${canonicalUrl(manifest, "/sitemap.xml")})`,
98
- "## Sections",
99
- groups.length ? groups.join(`
100
- `) : `- [${rootGroup?.title ?? "Home"}](${canonicalUrl(
101
- manifest,
102
- rootGroup?.path ?? "/",
103
- rootGroup?.key
104
- )})`,
105
- "## Pages",
106
- pages.length ? pages.join(`
107
- `) : `- [${rootGroup?.title ?? "Home"}](${canonicalUrl(
108
- manifest,
109
- rootGroup?.path ?? "/",
110
- rootGroup?.key
111
- )})`,
112
- ""
113
- ].join(`
114
-
115
- `);
116
344
  }
117
- function createSitemapMarkdownRoute(manifest, artifactManifest) {
345
+ function createSitemapMarkdownRoute(manifest, artifactManifest, options = {}) {
118
346
  return async function() {
119
347
  return createCachedTextResponse({
120
- body: await sitemapMarkdown(manifest, artifactManifest),
348
+ body: await sitemapMarkdown(manifest, artifactManifest, options),
121
349
  contentType: "text/markdown; charset=utf-8"
122
350
  });
123
351
  };
@@ -0,0 +1,34 @@
1
+ type NotFoundLink = {
2
+ title: string;
3
+ href: string;
4
+ description?: string;
5
+ kind?: "sitemap" | "sitemap-md" | "llms" | "llms-full";
6
+ };
7
+ type NotFoundScope = {
8
+ id: string;
9
+ path: string;
10
+ group?: string;
11
+ origin?: string;
12
+ describedBy?: string;
13
+ htmlPath: string;
14
+ recommendations: readonly NotFoundLink[];
15
+ indexes: readonly NotFoundLink[];
16
+ markdown: string;
17
+ };
18
+ declare function resolveNotFoundScope({ scopes, pathname, }: {
19
+ scopes: readonly NotFoundScope[];
20
+ pathname: string;
21
+ }): NotFoundScope | undefined;
22
+ declare function serializeNotFoundMarkdown({ recommendations, indexes, }: {
23
+ recommendations: readonly NotFoundLink[];
24
+ indexes: readonly NotFoundLink[];
25
+ }): string;
26
+ declare function createNotFoundTextResponse({ scope, pathname, method, contentType, vary, }: {
27
+ scope?: NotFoundScope;
28
+ pathname?: string;
29
+ method: string;
30
+ contentType?: "text/markdown; charset=utf-8" | "text/plain; charset=utf-8";
31
+ vary?: boolean;
32
+ }): Response;
33
+
34
+ export { type NotFoundLink, type NotFoundScope, createNotFoundTextResponse, resolveNotFoundScope, serializeNotFoundMarkdown };