@publish.os/nextjs 0.0.1-alpha.81 → 0.0.1-alpha.91

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 (265) hide show
  1. package/compiler-assets/nextjs/defaults/app/globals.css +1 -0
  2. package/compiler-assets/nextjs/defaults/group/index.tsx +50 -0
  3. package/compiler-assets/nextjs/defaults/group/layout.tsx +8 -8
  4. package/compiler-assets/nextjs/defaults/group/page.tsx +44 -43
  5. package/compiler-assets/nextjs/defaults/project/next.config.mjs +33 -13
  6. package/compiler-assets/nextjs/defaults/project/tsconfig.json.template +10 -3
  7. package/compiler-assets/nextjs/defaults/root/css/animation.css +131 -0
  8. package/compiler-assets/nextjs/defaults/root/css/components/code-block.css +18 -0
  9. package/compiler-assets/nextjs/defaults/root/css/components/dialog.css +4 -1
  10. package/compiler-assets/nextjs/defaults/root/css/components/menu.css +1 -1
  11. package/compiler-assets/nextjs/defaults/root/css/components/navigation-menu.css +1 -1
  12. package/compiler-assets/nextjs/defaults/root/css/components/popover.css +1 -1
  13. package/compiler-assets/nextjs/defaults/root/css/components/select.css +1 -1
  14. package/compiler-assets/nextjs/defaults/root/css/components/tooltip.css +1 -1
  15. package/compiler-assets/nextjs/defaults/root/css/shadow.css +6 -25
  16. package/compiler-assets/nextjs/defaults/root/css/typography.css +51 -68
  17. package/compiler-assets/nextjs/defaults/root/globals.css +25 -0
  18. package/compiler-assets/nextjs/defaults/root/{page.tsx → index.tsx} +6 -2
  19. package/compiler-assets/nextjs/defaults/root/layout.tsx +7 -1
  20. package/compiler-assets/nextjs/defaults/root/theme.css +22 -22
  21. package/compiler-assets/nextjs/shims/document.tsx +38 -0
  22. package/compiler-assets/nextjs/shims/generated-group-page.tsx +19 -2
  23. package/compiler-assets/nextjs/shims/generated-leaf-page.tsx +18 -2
  24. package/compiler-assets/nextjs/shims/global-layout.tsx +19 -85
  25. package/compiler-assets/nextjs/shims/global-not-found.tsx +69 -0
  26. package/compiler-assets/nextjs/shims/markdown-route.ts +2 -0
  27. package/compiler-assets/nextjs/shims/metadata-icons.tsx +39 -0
  28. package/compiler-assets/nextjs/shims/not-found-content.tsx +53 -0
  29. package/compiler-assets/nextjs/shims/not-found-navigation.tsx +60 -0
  30. package/compiler-assets/nextjs/shims/proxy.ts +143 -65
  31. package/compiler-assets/nextjs/shims/publish-os-theme-provider.tsx +76 -15
  32. package/compiler-assets/nextjs/shims/root-page.tsx +7 -1
  33. package/compiler-assets/nextjs/shims/site-fenced-code-block.tsx +30 -0
  34. package/compiler-assets/nextjs/shims/site-heading-level.tsx +14 -0
  35. package/compiler-assets/nextjs/shims/site-mdx-components.tsx +112 -0
  36. package/compiler-assets/nextjs/shims/site-mdx.tsx +17 -0
  37. package/compiler-assets/nextjs/shims/theme-defaults.css +41 -25
  38. package/dist/build-operation-5QMLXF7N.js +89 -0
  39. package/dist/{button-CFdx-ohV.d.ts → button-BdCScEKi.d.ts} +6 -6
  40. package/dist/capture-local-source-WGGDIUU2.js +258 -0
  41. package/dist/chunk-22RSSUNV.js +13 -0
  42. package/dist/chunk-4BC2L2KA.js +620 -0
  43. package/dist/chunk-5J3YUNRY.js +121 -0
  44. package/dist/chunk-5KAD7W53.js +248 -0
  45. package/dist/chunk-6C65KV7O.js +142 -0
  46. package/dist/chunk-6D2E6UMD.js +695 -0
  47. package/dist/chunk-7NY22B5U.js +161 -0
  48. package/dist/chunk-AI2UULNX.js +9 -0
  49. package/dist/chunk-EFO6AWXN.js +19 -0
  50. package/dist/chunk-F3AGNDF4.js +2377 -0
  51. package/dist/chunk-GBPLER5H.js +426 -0
  52. package/dist/chunk-IL4RJOKI.js +186 -0
  53. package/dist/chunk-NNBJZPFM.js +193 -0
  54. package/dist/chunk-ORIUWJBQ.js +58 -0
  55. package/dist/chunk-OXOFRXEI.js +7129 -0
  56. package/dist/chunk-UYGCOWRF.js +1709 -0
  57. package/dist/chunk-WL75GQ5M.js +80 -0
  58. package/dist/compiler.d.ts +54 -7
  59. package/dist/compiler.js +121 -13147
  60. package/dist/components/blocks/agent-actions.d.ts +81 -0
  61. package/dist/components/blocks/agent-actions.js +594 -0
  62. package/dist/components/blocks/toc.d.ts +43 -0
  63. package/dist/components/blocks/toc.js +136 -0
  64. package/dist/components/ui/button.d.ts +5 -0
  65. package/dist/components/ui/button.js +94 -0
  66. package/dist/compose-CVBJRAF6.js +16 -0
  67. package/dist/config/createNextConfig.js +27 -0
  68. package/dist/dev-operation-OSHHWRWK.js +1095 -0
  69. package/dist/framework-selection-ZVO323PK.js +11 -0
  70. package/dist/ide-support-CU6Z5PVR.js +16 -0
  71. package/dist/index.d.ts +55 -4
  72. package/dist/jsx-dev-runtime.d.ts +6 -0
  73. package/dist/jsx-dev-runtime.js +100 -0
  74. package/dist/jsx-runtime.d.ts +7 -0
  75. package/dist/jsx-runtime.js +97 -0
  76. package/dist/kernel/components/blocks/AgentActions.d.ts +35 -6
  77. package/dist/kernel/components/blocks/AgentActions.js +401 -150
  78. package/dist/kernel/components/blocks/agent-actions.d.ts +5 -0
  79. package/dist/kernel/components/blocks/agent-actions.js +594 -0
  80. package/dist/kernel/components/blocks/animated-icon-swap.js +1 -1
  81. package/dist/kernel/components/blocks/color-palette.js +4 -4
  82. package/dist/kernel/components/blocks/logo-block.js +3 -3
  83. package/dist/kernel/components/blocks/nav-breadcrumb.d.ts +10 -2
  84. package/dist/kernel/components/blocks/nav-breadcrumb.js +22 -7
  85. package/dist/kernel/components/blocks/navbar.d.ts +2 -2
  86. package/dist/kernel/components/blocks/navbar.js +406 -65
  87. package/dist/kernel/components/blocks/navigation-progress.js +6 -3
  88. package/dist/kernel/components/blocks/next-prev.d.ts +1 -1
  89. package/dist/kernel/components/blocks/next-prev.js +12 -24
  90. package/dist/kernel/components/blocks/page-list.d.ts +1 -1
  91. package/dist/kernel/components/blocks/page-list.js +7 -6
  92. package/dist/kernel/components/blocks/search.d.ts +83 -58
  93. package/dist/kernel/components/blocks/search.js +554 -428
  94. package/dist/kernel/components/blocks/sidebar-node.d.ts +2 -2
  95. package/dist/kernel/components/blocks/sidebar-node.js +12 -10
  96. package/dist/kernel/components/blocks/sidebar.d.ts +3 -3
  97. package/dist/kernel/components/blocks/sidebar.js +24 -14
  98. package/dist/kernel/components/blocks/theme-toggle.d.ts +2 -2
  99. package/dist/kernel/components/blocks/theme-toggle.js +47 -1
  100. package/dist/kernel/components/blocks/toc-client.d.ts +40 -0
  101. package/dist/kernel/components/blocks/toc-client.js +495 -0
  102. package/dist/kernel/components/blocks/toc.d.ts +19 -1
  103. package/dist/kernel/components/blocks/toc.js +122 -180
  104. package/dist/kernel/components/mdx/components/blockquote.js +2 -2
  105. package/dist/kernel/components/mdx/components/callout.d.ts +5 -7
  106. package/dist/kernel/components/mdx/components/callout.js +67 -36
  107. package/dist/kernel/components/mdx/components/code-block.d.ts +5 -2
  108. package/dist/kernel/components/mdx/components/code-block.js +106 -5
  109. package/dist/kernel/components/mdx/components/copy-code-button.d.ts +8 -0
  110. package/dist/kernel/components/mdx/components/copy-code-button.js +61 -0
  111. package/dist/kernel/components/mdx/components/figure-caption.d.ts +1 -1
  112. package/dist/kernel/components/mdx/components/figure-caption.js +4 -3
  113. package/dist/kernel/components/mdx/components/figure.d.ts +6 -2
  114. package/dist/kernel/components/mdx/components/figure.js +24 -14
  115. package/dist/kernel/components/mdx/components/footnotes.js +1 -1
  116. package/dist/kernel/components/mdx/components/heading-copy-link.js +4 -4
  117. package/dist/kernel/components/mdx/components/heading.js +6 -3
  118. package/dist/kernel/components/mdx/components/hr.js +2 -2
  119. package/dist/kernel/components/mdx/components/image-zoom.js +2 -2
  120. package/dist/kernel/components/mdx/components/image.d.ts +1 -1
  121. package/dist/kernel/components/mdx/components/image.js +94 -68
  122. package/dist/kernel/components/mdx/components/inline-code.js +2 -2
  123. package/dist/kernel/components/mdx/components/kbd.d.ts +2 -2
  124. package/dist/kernel/components/mdx/components/kbd.js +5 -4
  125. package/dist/kernel/components/mdx/components/link.d.ts +35 -4
  126. package/dist/kernel/components/mdx/components/link.js +3 -3
  127. package/dist/kernel/components/mdx/components/paragraph.js +2 -5
  128. package/dist/kernel/components/mdx/components/strikethrough.js +1 -1
  129. package/dist/kernel/components/mdx/components/table.js +2 -2
  130. package/dist/kernel/components/mdx/components/task-list.js +2 -2
  131. package/dist/kernel/components/mdx/components/video-player.d.ts +6 -2
  132. package/dist/kernel/components/mdx/components/video-player.js +8 -4
  133. package/dist/kernel/components/mdx/components/video.d.ts +5 -3
  134. package/dist/kernel/components/mdx/components/video.js +8 -6
  135. package/dist/kernel/components/mdx/error-boundary.js +2 -2
  136. package/dist/kernel/components/mdx/error-fallback.js +1 -1
  137. package/dist/kernel/components/mdx/mdx.d.ts +28 -14
  138. package/dist/kernel/components/mdx/mdx.js +336 -63
  139. package/dist/kernel/components/mdx/rehype-heading-ids.d.ts +1 -0
  140. package/dist/kernel/components/mdx/rehype-heading-ids.js +6 -4
  141. package/dist/kernel/components/next-image.d.ts +12 -0
  142. package/dist/kernel/components/next-image.js +61 -0
  143. package/dist/kernel/components/ui/accordion.js +1 -1
  144. package/dist/kernel/components/ui/breadcrumb-trail.d.ts +6 -23
  145. package/dist/kernel/components/ui/breadcrumb-trail.js +2 -2
  146. package/dist/kernel/components/ui/breadcrumb.d.ts +11 -3
  147. package/dist/kernel/components/ui/breadcrumb.js +10 -8
  148. package/dist/kernel/components/ui/button-group.js +8 -7
  149. package/dist/kernel/components/ui/button.d.ts +58 -6
  150. package/dist/kernel/components/ui/button.js +43 -39
  151. package/dist/kernel/components/ui/card.d.ts +2 -2
  152. package/dist/kernel/components/ui/card.js +1 -1
  153. package/dist/kernel/components/ui/dialog.js +1 -1
  154. package/dist/kernel/components/ui/drawer.d.ts +3 -1
  155. package/dist/kernel/components/ui/drawer.js +6 -2
  156. package/dist/kernel/components/ui/input.d.ts +2 -2
  157. package/dist/kernel/components/ui/input.js +1 -1
  158. package/dist/kernel/components/ui/kbd.js +10 -17
  159. package/dist/kernel/components/ui/link.d.ts +11 -3
  160. package/dist/kernel/components/ui/link.js +12 -11
  161. package/dist/kernel/components/ui/menu.js +6 -6
  162. package/dist/kernel/components/ui/mod-key.d.ts +10 -0
  163. package/dist/kernel/components/ui/mod-key.js +36 -0
  164. package/dist/kernel/components/ui/navigation-menu.js +3 -3
  165. package/dist/kernel/components/ui/popover.js +1 -1
  166. package/dist/kernel/components/ui/progress.js +2 -2
  167. package/dist/kernel/components/ui/scroll-area.js +5 -5
  168. package/dist/kernel/components/ui/select.js +8 -11
  169. package/dist/kernel/components/ui/separator.js +1 -1
  170. package/dist/kernel/components/ui/table.js +1 -1
  171. package/dist/kernel/components/ui/tabs.js +1 -1
  172. package/dist/kernel/components/ui/tag.js +1 -1
  173. package/dist/kernel/components/ui/text.d.ts +2 -2
  174. package/dist/kernel/components/ui/text.js +1 -1
  175. package/dist/kernel/components/ui/toast.js +1 -1
  176. package/dist/kernel/components/ui/tooltip.js +1 -1
  177. package/dist/kernel/defaults.registry.d.ts +11 -24
  178. package/dist/kernel/defaults.registry.js +11 -26
  179. package/dist/kernel/routes/agent/markdown.d.ts +3 -1
  180. package/dist/kernel/routes/agent/markdown.js +219 -48
  181. package/dist/kernel/routes/layouts/group.d.ts +1 -1
  182. package/dist/kernel/routes/layouts/group.js +5 -7
  183. package/dist/kernel/routes/metadata/feed.d.ts +1 -1
  184. package/dist/kernel/routes/metadata/feed.js +111 -81
  185. package/dist/kernel/routes/metadata/llms.d.ts +12 -3
  186. package/dist/kernel/routes/metadata/llms.js +156 -59
  187. package/dist/kernel/routes/metadata/og-image.js +1 -1
  188. package/dist/kernel/routes/metadata/robots.d.ts +1 -1
  189. package/dist/kernel/routes/metadata/robots.js +2 -2
  190. package/dist/kernel/routes/metadata/sitemap.d.ts +26 -4
  191. package/dist/kernel/routes/metadata/sitemap.js +206 -38
  192. package/dist/kernel/routes/not-found.d.ts +34 -0
  193. package/dist/kernel/routes/not-found.js +213 -0
  194. package/dist/kernel/routes/pages/group.d.ts +2 -2
  195. package/dist/kernel/routes/pages/group.js +21 -13
  196. package/dist/kernel/routes/pages/leaf.d.ts +28 -1
  197. package/dist/kernel/routes/pages/leaf.js +25 -16
  198. package/dist/kernel/routes/pages/root.js +19 -13
  199. package/dist/keyboard-shortcuts.js +1 -1
  200. package/dist/resolvers/manifest-resolver.js +29 -6
  201. package/dist/search.d.ts +6 -7
  202. package/dist/search.js +52 -29
  203. package/dist/{sidebar-types-Bgchdfd6.d.ts → sidebar-types-DKpR27II.d.ts} +1 -1
  204. package/dist/theme-scope.js +1 -1
  205. package/dist/{types-DHBm7-j6.d.ts → types-CJWRG05y.d.ts} +20 -1
  206. package/dist/{types-B_b3C0U6.d.ts → types-CUtrppxt.d.ts} +8 -2
  207. package/dist/{types-CIwwieNw.d.ts → types-J2w_puPF.d.ts} +11 -10
  208. package/dist/types.d.ts +15 -6
  209. package/dist/utils/heading-ids.js +30 -11
  210. package/dist/utils/toc-selection.d.ts +7 -0
  211. package/dist/utils/toc-selection.js +14 -0
  212. package/dist/validate-local-source-SV44DBQT.js +16 -0
  213. package/dist/validate-publish-os-source-NZJF3TB2.js +14 -0
  214. package/init/seed/minimal/.gitignore +1 -0
  215. package/init/seed/minimal/publish.os/assets/blog/hello-world.svg +13 -0
  216. package/init/seed/minimal/publish.os/assets/favicon.dark.svg +13 -0
  217. package/init/seed/minimal/publish.os/assets/favicon.svg +13 -0
  218. package/init/seed/minimal/publish.os/blog/content/hello-world.mdx +48 -0
  219. package/init/seed/minimal/publish.os/blog/content/series-a.mdx +11 -0
  220. package/init/seed/minimal/publish.os/blog/index.tsx +82 -0
  221. package/init/seed/minimal/publish.os/blog/layout.tsx +13 -0
  222. package/init/seed/minimal/publish.os/blog/page.tsx +76 -0
  223. package/init/seed/minimal/publish.os/components/blog/copy-link.tsx +64 -0
  224. package/init/seed/minimal/publish.os/docs/content/get-started.mdx +6 -11
  225. package/init/seed/minimal/publish.os/docs/content/groups.mdx +6 -7
  226. package/init/seed/minimal/publish.os/docs/content/{theme.mdx → themes.mdx} +14 -12
  227. package/init/seed/minimal/publish.os/publish.os.config.json +7 -7
  228. package/init/seed/minimal/publish.os/theme.css +52 -24
  229. package/init/seed/minimal/publish.os/tsconfig.json +3 -0
  230. package/init/seed/minimal/seed.json +12 -2
  231. package/init/seed/scratch/publish.os/docs/content/get-started.mdx +6 -0
  232. package/init/seed/scratch/publish.os/publish.os.config.json +4 -0
  233. package/init/seed/scratch/seed.json +5 -0
  234. package/package.json +55 -44
  235. package/release/app/phosphor/package.json +5 -5
  236. package/release/app/phosphor/pnpm-lock.yaml.template +553 -377
  237. package/release/app/phosphor/pnpm-workspace.yaml +3 -0
  238. package/release/compiler/package.json +5 -3
  239. package/release/compiler/pnpm-lock.yaml.template +500 -303
  240. package/release/compiler/pnpm-workspace.yaml +3 -0
  241. package/release/release.json +8 -37
  242. package/compiler-assets/nextjs/defaults/group/leaf.tsx +0 -48
  243. package/dist/icons.d.ts +0 -1
  244. package/dist/icons.js +0 -2
  245. package/dist/kernel/components/blocks/design-system-preview.d.ts +0 -61
  246. package/dist/kernel/components/blocks/design-system-preview.js +0 -648
  247. package/dist/kernel/components/blocks/link-playground.d.ts +0 -5
  248. package/dist/kernel/components/blocks/link-playground.js +0 -744
  249. package/dist/kernel/components/blocks/navigation-progress-playground.d.ts +0 -5
  250. package/dist/kernel/components/blocks/navigation-progress-playground.js +0 -629
  251. package/dist/kernel/components/mdx/components/pre.d.ts +0 -6
  252. package/dist/kernel/components/mdx/components/pre.js +0 -18
  253. package/dist/kernel/components/ui/meta-key.d.ts +0 -17
  254. package/dist/kernel/components/ui/meta-key.js +0 -9
  255. package/dist/kernel/components/ui/theme-toggle.d.ts +0 -24
  256. package/dist/kernel/components/ui/theme-toggle.js +0 -58
  257. package/dist/kernel/framework-icons.d.ts +0 -1
  258. package/dist/kernel/framework-icons.js +0 -39
  259. package/dist/link-CYaCRDb6.d.ts +0 -35
  260. package/release/app/lucide/package.json +0 -30
  261. package/release/app/lucide/pnpm-lock.yaml.template +0 -2905
  262. package/release/app/lucide/pnpm-workspace.yaml +0 -11
  263. package/release/app/tabler/package.json +0 -30
  264. package/release/app/tabler/pnpm-lock.yaml.template +0 -2911
  265. package/release/app/tabler/pnpm-workspace.yaml +0 -11
@@ -3,8 +3,8 @@ import { tags } from "@publish.os/nextjs/cache/tags";
3
3
  import { cacheLife, cacheTag } from "next/cache";
4
4
 
5
5
  // src/lib/runtime/metadata/canonical-url.ts
6
- function canonicalUrl(manifest, path) {
7
- let origin = manifest.site.url?.replace(/\/+$/, "");
6
+ function canonicalUrl(manifest, path, group) {
7
+ let origin = (group && manifest.groups[group]?.origin) ?? manifest.site.origin;
8
8
  if (!origin) return path;
9
9
  try {
10
10
  return new URL(path, `${origin}/`).toString();
@@ -13,6 +13,122 @@ function canonicalUrl(manifest, path) {
13
13
  }
14
14
  }
15
15
 
16
+ // src/lib/runtime/metadata/discovery-content.ts
17
+ function discoveryOrigin(manifest, group) {
18
+ return (group ? manifest.groups[group]?.origin : void 0) ?? manifest.site.origin;
19
+ }
20
+ function pathWithin(path, basePath) {
21
+ return basePath === "/" || path === basePath || path.startsWith(`${basePath}/`);
22
+ }
23
+ function discoveryPages({
24
+ manifest,
25
+ group,
26
+ scope,
27
+ limit
28
+ }) {
29
+ let origin = discoveryOrigin(manifest, group), basePath = group ? manifest.groups[group]?.path ?? "/" : "/", pages = manifest.pages.filter((page) => page.status !== "published" || discoveryOrigin(manifest, page.group) !== origin ? !1 : !group || scope === "site" ? !0 : pathWithin(page.path, basePath) ? page.group === group || scope !== "self" && page.group.startsWith(`${group}/`) : !1);
30
+ return limit ? pages.slice(0, limit) : pages;
31
+ }
32
+ function groupDiscoveryPages({
33
+ manifest,
34
+ pages
35
+ }) {
36
+ let sections = /* @__PURE__ */ new Map();
37
+ for (let page of pages) {
38
+ let group = manifest.groups[page.group], key = group ? page.group : "", section = sections.get(key);
39
+ section || (section = {
40
+ ...group ? { group: page.group } : {},
41
+ title: group ? group.key === "__root" ? manifest.site.name : group.title : "Pages",
42
+ pages: []
43
+ }, sections.set(key, section)), section.pages.push(page);
44
+ }
45
+ return [...sections.values()].sort(
46
+ (a, b) => (manifest.groups[a.group ?? ""]?.path ?? "/").localeCompare(
47
+ manifest.groups[b.group ?? ""]?.path ?? "/"
48
+ ) || a.title.localeCompare(b.title)
49
+ );
50
+ }
51
+
52
+ // src/lib/runtime/metadata/llms-serialization.ts
53
+ function inlineText(value) {
54
+ return value.replace(/[\r\n]+/g, " ").replace(/([\\`*_[\]<>])/g, "\\$1");
55
+ }
56
+ function markdownLink(link) {
57
+ let url = link.url.replace(
58
+ /[\s()<>]/g,
59
+ (value) => value === "(" ? "%28" : value === ")" ? "%29" : encodeURIComponent(value)
60
+ );
61
+ return `[${inlineText(link.title)}](${url})`;
62
+ }
63
+ function serializeLlmsIndex(input) {
64
+ let body = (input.sections ?? [
65
+ { title: "Pages", pages: input.pages ?? [] }
66
+ ]).map((section) => {
67
+ let lines = [
68
+ ...(section.links ?? []).map((link) => `- ${markdownLink(link)}`),
69
+ ...section.pages.map((page) => {
70
+ let description = input.includeDescriptions && page.description ? `: ${inlineText(page.description)}` : "", alternate = page.alternate ? ` (${markdownLink(page.alternate)})` : "";
71
+ return `- ${markdownLink(page)}${alternate}${description}`;
72
+ })
73
+ ];
74
+ return `## ${inlineText(section.title)}
75
+
76
+ ${lines.join(`
77
+ `)}`;
78
+ }).join(`
79
+
80
+ `), linkLines = (input.links ?? []).map(
81
+ (link) => `- ${markdownLink(link)}`
82
+ ), linkSection = linkLines.length ? `
83
+
84
+ ## Group LLM indexes
85
+
86
+ ${linkLines.join(`
87
+ `)}` : "", otherGroupLines = (input.otherGroupLinks ?? []).map(
88
+ (link) => `- ${markdownLink(link)}`
89
+ ), otherGroupSection = otherGroupLines.length ? `
90
+
91
+ ## Other content groups
92
+
93
+ ${otherGroupLines.join(`
94
+ `)}` : "";
95
+ return `# ${inlineText(input.title)}
96
+
97
+ > ${inlineText(input.summary)}
98
+
99
+ ${body}${linkSection}${otherGroupSection}
100
+ `;
101
+ }
102
+ function serializeLlmsFull(input) {
103
+ let encoder = new TextEncoder(), byteLength = (value) => encoder.encode(value).byteLength, references = [
104
+ input.indexUrl ? `> LLMS index: ${input.indexUrl}` : void 0,
105
+ input.sitemapUrl ? `> Sitemap: ${input.sitemapUrl}` : void 0
106
+ ].filter(Boolean).join(`
107
+ `), header = `# ${input.title} Full Content
108
+
109
+ ${references ? `${references}
110
+
111
+ ` : ""}`, sections = [], totalBytes = byteLength(header), included = 0, truncated = !1;
112
+ for (let artifact of [...input.artifacts].sort(
113
+ (a, b) => a.markdownPath.localeCompare(b.markdownPath)
114
+ )) {
115
+ let section = `---
116
+
117
+ ${artifact.body.trim()}
118
+
119
+ `, sectionBytes = byteLength(section);
120
+ if (totalBytes + sectionBytes > input.maxBytes) {
121
+ truncated = !0;
122
+ break;
123
+ }
124
+ sections.push(section), totalBytes += sectionBytes, included += 1;
125
+ }
126
+ let footer = truncated ? `
127
+ > Truncated at ${included} of ${input.totalCount ?? input.artifacts.length} Markdown pages to stay under ${input.maxBytes} bytes.
128
+ ` : "";
129
+ return `${header}${sections.join("")}${footer}`;
130
+ }
131
+
16
132
  // src/lib/runtime/response/cached-text-response.ts
17
133
  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
134
  function cacheControl(policy) {
@@ -34,48 +150,45 @@ function createCachedTextResponse(options) {
34
150
  }
35
151
 
36
152
  // 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 = {}) {
153
+ var DEFAULT_LLMS_FULL_MAX_BYTES = 1e6;
154
+ async function llmsTxt(manifest, options = {}, artifactManifest) {
48
155
  "use cache";
49
156
  cacheLife("page"), cacheTag(
50
157
  tags.site(),
51
158
  tags.llms(options.group ?? options.scope ?? "root"),
52
159
  tags.manifest(manifest.contentHash)
53
160
  );
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)})${description}`;
57
- }), linkLines = (options.links ?? []).map(
58
- (link) => `- [${link.title}](${canonicalUrl(manifest, link.path)})`
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
- `;
161
+ let pages = discoveryPages({ manifest, ...options }), group = options.group ? manifest.groups[options.group] : void 0;
162
+ return serializeLlmsIndex({
163
+ title: group?.title ?? manifest.site.name,
164
+ summary: manifest.site.description ? manifest.site.description : `Agent-readable index for ${manifest.site.name}.`,
165
+ sections: groupDiscoveryPages({ manifest, pages }).map((section) => ({
166
+ title: section.title,
167
+ pages: section.pages.map((page) => ({
168
+ title: page.title,
169
+ url: canonicalUrl(
170
+ manifest,
171
+ artifactManifest?.byHtmlPath[page.path] ?? page.path,
172
+ page.group
173
+ ),
174
+ description: page.description
175
+ }))
176
+ })),
177
+ includeDescriptions: options.includeDescriptions,
178
+ links: options.links?.map((link) => ({
179
+ title: link.title,
180
+ url: canonicalUrl(manifest, link.path, link.group)
181
+ })),
182
+ otherGroupLinks: options.otherGroupLinks?.map((link) => ({
183
+ title: link.title,
184
+ url: canonicalUrl(manifest, link.path, link.group)
185
+ }))
186
+ });
74
187
  }
75
- function createLlmsTxtRoute(manifest, options = {}) {
188
+ function createLlmsTxtRoute(manifest, options = {}, artifactManifest) {
76
189
  return async function() {
77
190
  return createCachedTextResponse({
78
- body: await llmsTxt(manifest, options),
191
+ body: await llmsTxt(manifest, options, artifactManifest),
79
192
  contentType: "text/plain; charset=utf-8"
80
193
  });
81
194
  };
@@ -89,30 +202,14 @@ function createPrecomputedLlmsTxtRoute(output) {
89
202
  };
90
203
  }
91
204
  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}`;
205
+ return serializeLlmsFull({
206
+ title: manifest.site.name,
207
+ indexUrl: options.indexPath === !1 ? void 0 : canonicalUrl(manifest, options.indexPath ?? "/llms.txt"),
208
+ sitemapUrl: options.sitemapPath === !1 ? void 0 : canonicalUrl(manifest, options.sitemapPath ?? "/sitemap.md"),
209
+ // Route factories serialize their supplied artifacts; generated output filters by origin.
210
+ artifacts: Object.values(artifacts),
211
+ maxBytes: options.maxBytes ?? DEFAULT_LLMS_FULL_MAX_BYTES
212
+ });
116
213
  }
117
214
  async function llmsFullTxtResponse(manifest, artifacts, options = {}) {
118
215
  return createCachedTextResponse({
@@ -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,4 +1,4 @@
1
- import { M as ManifestLike } from '../../../types-CIwwieNw.js';
1
+ import { M as ManifestLike } from '../../../types-J2w_puPF.js';
2
2
 
3
3
  declare function createRobotsTxtRoute(manifest: ManifestLike): () => Promise<Response>;
4
4
 
@@ -3,8 +3,8 @@ import { tags } from "@publish.os/nextjs/cache/tags";
3
3
  import { cacheLife, cacheTag } from "next/cache";
4
4
 
5
5
  // src/lib/runtime/metadata/canonical-url.ts
6
- function canonicalUrl(manifest, path) {
7
- let origin = manifest.site.url?.replace(/\/+$/, "");
6
+ function canonicalUrl(manifest, path, group) {
7
+ let origin = (group && manifest.groups[group]?.origin) ?? manifest.site.origin;
8
8
  if (!origin) return path;
9
9
  try {
10
10
  return new URL(path, `${origin}/`).toString();
@@ -1,7 +1,29 @@
1
1
  import { MarkdownRouteArtifactManifest } from '../agent/markdown.js';
2
- import { M as ManifestLike } from '../../../types-CIwwieNw.js';
2
+ import { M as ManifestLike } from '../../../types-J2w_puPF.js';
3
+ import '../not-found.js';
3
4
 
4
- declare function createSitemapXmlRoute(manifest: ManifestLike): () => Promise<Response>;
5
- declare function createSitemapMarkdownRoute(manifest: ManifestLike, artifactManifest: MarkdownRouteArtifactManifest): () => Promise<Response>;
5
+ type SitemapReference = {
6
+ path: string;
7
+ group?: string;
8
+ };
9
+ type SitemapRouteOptions = {
10
+ group?: string;
11
+ path?: string;
12
+ sitemaps?: SitemapReference[];
13
+ exclude?: SitemapReference[];
14
+ };
15
+ type SitemapMarkdownRouteOptions = {
16
+ group?: string;
17
+ scope?: "site" | "group" | "self";
18
+ links?: Array<SitemapReference & {
19
+ title: string;
20
+ }>;
21
+ otherGroupLinks?: Array<SitemapReference & {
22
+ title: string;
23
+ }>;
24
+ markdownAlternates?: boolean;
25
+ };
26
+ declare function createSitemapXmlRoute(manifest: ManifestLike, options?: SitemapRouteOptions): () => Promise<Response>;
27
+ declare function createSitemapMarkdownRoute(manifest: ManifestLike, artifactManifest: MarkdownRouteArtifactManifest, options?: SitemapMarkdownRouteOptions): () => Promise<Response>;
6
28
 
7
- export { createSitemapMarkdownRoute, createSitemapXmlRoute };
29
+ export { type SitemapMarkdownRouteOptions, type SitemapRouteOptions, createSitemapMarkdownRoute, createSitemapXmlRoute };
@@ -3,8 +3,8 @@ import { tags } from "@publish.os/nextjs/cache/tags";
3
3
  import { cacheLife, cacheTag } from "next/cache";
4
4
 
5
5
  // src/lib/runtime/metadata/canonical-url.ts
6
- function canonicalUrl(manifest, path) {
7
- let origin = manifest.site.url?.replace(/\/+$/, "");
6
+ function canonicalUrl(manifest, path, group) {
7
+ let origin = (group && manifest.groups[group]?.origin) ?? manifest.site.origin;
8
8
  if (!origin) return path;
9
9
  try {
10
10
  return new URL(path, `${origin}/`).toString();
@@ -13,6 +13,93 @@ function canonicalUrl(manifest, path) {
13
13
  }
14
14
  }
15
15
 
16
+ // src/lib/runtime/metadata/discovery-content.ts
17
+ function discoveryOrigin(manifest, group) {
18
+ return (group ? manifest.groups[group]?.origin : void 0) ?? manifest.site.origin;
19
+ }
20
+ function pathWithin(path, basePath) {
21
+ return basePath === "/" || path === basePath || path.startsWith(`${basePath}/`);
22
+ }
23
+ function discoveryPages({
24
+ manifest,
25
+ group,
26
+ scope,
27
+ limit
28
+ }) {
29
+ let origin = discoveryOrigin(manifest, group), basePath = group ? manifest.groups[group]?.path ?? "/" : "/", pages = manifest.pages.filter((page) => page.status !== "published" || discoveryOrigin(manifest, page.group) !== origin ? !1 : !group || scope === "site" ? !0 : pathWithin(page.path, basePath) ? page.group === group || scope !== "self" && page.group.startsWith(`${group}/`) : !1);
30
+ return limit ? pages.slice(0, limit) : pages;
31
+ }
32
+ function groupDiscoveryPages({
33
+ manifest,
34
+ pages
35
+ }) {
36
+ let sections = /* @__PURE__ */ new Map();
37
+ for (let page of pages) {
38
+ let group = manifest.groups[page.group], key = group ? page.group : "", section = sections.get(key);
39
+ section || (section = {
40
+ ...group ? { group: page.group } : {},
41
+ title: group ? group.key === "__root" ? manifest.site.name : group.title : "Pages",
42
+ pages: []
43
+ }, sections.set(key, section)), section.pages.push(page);
44
+ }
45
+ return [...sections.values()].sort(
46
+ (a, b) => (manifest.groups[a.group ?? ""]?.path ?? "/").localeCompare(
47
+ manifest.groups[b.group ?? ""]?.path ?? "/"
48
+ ) || a.title.localeCompare(b.title)
49
+ );
50
+ }
51
+
52
+ // src/lib/runtime/metadata/llms-serialization.ts
53
+ function inlineText(value) {
54
+ return value.replace(/[\r\n]+/g, " ").replace(/([\\`*_[\]<>])/g, "\\$1");
55
+ }
56
+ function markdownLink(link) {
57
+ let url = link.url.replace(
58
+ /[\s()<>]/g,
59
+ (value) => value === "(" ? "%28" : value === ")" ? "%29" : encodeURIComponent(value)
60
+ );
61
+ return `[${inlineText(link.title)}](${url})`;
62
+ }
63
+ function serializeLlmsIndex(input) {
64
+ let body = (input.sections ?? [
65
+ { title: "Pages", pages: input.pages ?? [] }
66
+ ]).map((section) => {
67
+ let lines = [
68
+ ...(section.links ?? []).map((link) => `- ${markdownLink(link)}`),
69
+ ...section.pages.map((page) => {
70
+ let description = input.includeDescriptions && page.description ? `: ${inlineText(page.description)}` : "", alternate = page.alternate ? ` (${markdownLink(page.alternate)})` : "";
71
+ return `- ${markdownLink(page)}${alternate}${description}`;
72
+ })
73
+ ];
74
+ return `## ${inlineText(section.title)}
75
+
76
+ ${lines.join(`
77
+ `)}`;
78
+ }).join(`
79
+
80
+ `), linkLines = (input.links ?? []).map(
81
+ (link) => `- ${markdownLink(link)}`
82
+ ), linkSection = linkLines.length ? `
83
+
84
+ ## Group LLM indexes
85
+
86
+ ${linkLines.join(`
87
+ `)}` : "", otherGroupLines = (input.otherGroupLinks ?? []).map(
88
+ (link) => `- ${markdownLink(link)}`
89
+ ), otherGroupSection = otherGroupLines.length ? `
90
+
91
+ ## Other content groups
92
+
93
+ ${otherGroupLines.join(`
94
+ `)}` : "";
95
+ return `# ${inlineText(input.title)}
96
+
97
+ > ${inlineText(input.summary)}
98
+
99
+ ${body}${linkSection}${otherGroupSection}
100
+ `;
101
+ }
102
+
16
103
  // src/lib/runtime/response/cached-text-response.ts
17
104
  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
105
  function cacheControl(policy) {
@@ -34,62 +121,143 @@ function createCachedTextResponse(options) {
34
121
  }
35
122
 
36
123
  // src/route-metadata-sitemap.ts
124
+ var ROOT_CONTENT_GROUP_KEY = "__root";
37
125
  function xmlEscape(value) {
38
- return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
126
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/'/g, "&apos;").replace(/"/g, "&quot;");
127
+ }
128
+ function sitemapDirectory(path) {
129
+ return path.slice(0, path.lastIndexOf("/") + 1) || "/";
39
130
  }
40
- async function sitemapXml(manifest) {
131
+ function rootMountedGroup(manifest, origin) {
132
+ return Object.values(manifest.groups).find(
133
+ (group) => group.key !== ROOT_CONTENT_GROUP_KEY && group.path === "/" && discoveryOrigin(manifest, group.key) === origin
134
+ );
135
+ }
136
+ async function sitemapXml(manifest, options) {
41
137
  "use cache";
42
138
  cacheLife("page"), cacheTag(tags.site(), tags.sitemap(), tags.manifest(manifest.contentHash));
43
- let urls = [
44
- "/",
45
- ...Object.values(manifest.groups).map((g) => g.path),
46
- ...manifest.pages.filter((page) => page.status === "published").map((page) => page.path)
47
- ];
139
+ let targetGroup = options.group ? manifest.groups[options.group] : void 0, directory = sitemapDirectory(
140
+ options.path ?? `${targetGroup?.path === "/" ? "" : targetGroup?.path ?? ""}/sitemap.xml`
141
+ ), origin = targetGroup ? discoveryOrigin(manifest, targetGroup.key) : manifest.site.origin;
142
+ if (options.sitemaps)
143
+ return `<?xml version="1.0" encoding="UTF-8"?>
144
+ <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
145
+ ${[
146
+ ...new Set(
147
+ options.sitemaps.filter(
148
+ (sitemap) => discoveryOrigin(manifest, sitemap.group) === origin
149
+ ).filter(
150
+ (sitemap) => sitemap.path.startsWith(directory) && sitemap.path !== options.path
151
+ ).map(
152
+ (sitemap) => canonicalUrl(manifest, sitemap.path, sitemap.group)
153
+ )
154
+ )
155
+ ].map((url) => ` <sitemap><loc>${xmlEscape(url)}</loc></sitemap>`).join(`
156
+ `)}
157
+ </sitemapindex>
158
+ `;
159
+ let homeGroup = targetGroup ?? rootMountedGroup(manifest, origin), groups = Object.values(manifest.groups).filter(
160
+ (group) => discoveryOrigin(manifest, group.key) === origin && (directory === "/" || group.path.startsWith(directory))
161
+ ), urls = [
162
+ {
163
+ path: homeGroup?.path ?? "/",
164
+ group: homeGroup?.key
165
+ },
166
+ ...groups.map((group) => ({ path: group.path, group: group.key })),
167
+ ...manifest.pages.filter((page) => page.status === "published").filter((page) => discoveryOrigin(manifest, page.group) === origin).map((page) => ({ path: page.path, group: page.group }))
168
+ ].filter(
169
+ ({ path }) => (directory === "/" || path.startsWith(directory)) && !(options.exclude ?? []).some(
170
+ (sitemap) => discoveryOrigin(manifest, sitemap.group) === origin && path.startsWith(sitemapDirectory(sitemap.path))
171
+ )
172
+ );
48
173
  return `<?xml version="1.0" encoding="UTF-8"?>
49
174
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
50
- ${[...new Set(urls)].map(
51
- (url) => ` <url><loc>${xmlEscape(canonicalUrl(manifest, url))}</loc></url>`
52
- ).join(`
175
+ ${[...new Map(
176
+ urls.map(({ path, group }) => {
177
+ let url = canonicalUrl(manifest, path, group);
178
+ return [url, url];
179
+ })
180
+ ).values()].map((url) => ` <url><loc>${xmlEscape(url)}</loc></url>`).join(`
53
181
  `)}
54
182
  </urlset>
55
183
  `;
56
184
  }
57
- function createSitemapXmlRoute(manifest) {
185
+ function createSitemapXmlRoute(manifest, options = {}) {
58
186
  return async function() {
59
187
  return createCachedTextResponse({
60
- body: await sitemapXml(manifest),
188
+ body: await sitemapXml(manifest, options),
61
189
  contentType: "application/xml; charset=utf-8"
62
190
  });
63
191
  };
64
192
  }
65
- async function sitemapMarkdown(manifest, artifactManifest) {
66
- let groups = Object.values(manifest.groups).sort((a, b) => a.path.localeCompare(b.path)).map(
67
- (group) => `- [${group.title}](${canonicalUrl(manifest, group.path)})`
68
- ), pages = manifest.pages.filter((page) => page.status === "published").sort((a, b) => a.path.localeCompare(b.path)).map((page) => {
69
- let markdownPath = artifactManifest.byHtmlPath[page.path], markdown = markdownPath ? ` ([Markdown](${canonicalUrl(manifest, markdownPath)}))` : "";
70
- return `- [${page.title}](${canonicalUrl(manifest, page.path)})${markdown}`;
193
+ async function sitemapMarkdown(manifest, artifactManifest, options) {
194
+ 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), groups = Object.values(manifest.groups).filter((group) => group.key !== ROOT_CONTENT_GROUP_KEY).filter((group) => discoveryOrigin(manifest, group.key) === origin).filter(
195
+ (group) => !targetGroup || options.scope === "site" || pathWithin(group.path, targetGroup.path) && (group.key === targetGroup.key || options.scope !== "self" && group.key.startsWith(`${targetGroup.key}/`))
196
+ ), pages = discoveryPages({ manifest, ...options }).sort(
197
+ (a, b) => a.path.localeCompare(b.path)
198
+ ), sections = groupDiscoveryPages({ manifest, pages });
199
+ for (let group of groups)
200
+ sections.some((section) => section.group === group.key) || sections.push({ group: group.key, title: group.title, pages: [] });
201
+ sections.sort(
202
+ (a, b) => (manifest.groups[a.group ?? ""]?.path ?? "/").localeCompare(
203
+ manifest.groups[b.group ?? ""]?.path ?? "/"
204
+ )
205
+ );
206
+ let links = options.links ?? [
207
+ { title: "LLMS index", path: "/llms.txt" },
208
+ { title: "Full LLMS index", path: "/llms-full.txt" },
209
+ { title: "XML sitemap", path: "/sitemap.xml" }
210
+ ];
211
+ return serializeLlmsIndex({
212
+ title: `${rootGroup?.title ?? manifest.site.name} Sitemap`,
213
+ summary: "Browse the published pages and their available Markdown versions.",
214
+ sections: [
215
+ ...links.length ? [
216
+ {
217
+ title: "Agent indexes",
218
+ pages: [],
219
+ links: links.map((link) => ({
220
+ title: link.title,
221
+ url: canonicalUrl(manifest, link.path, link.group)
222
+ }))
223
+ }
224
+ ] : [],
225
+ ...sections.map((section) => {
226
+ let group = manifest.groups[section.group ?? ""];
227
+ return {
228
+ title: section.title,
229
+ links: group && group.key !== ROOT_CONTENT_GROUP_KEY ? [
230
+ {
231
+ title: group.title,
232
+ url: canonicalUrl(manifest, group.path, group.key)
233
+ }
234
+ ] : [],
235
+ pages: section.pages.map((page) => {
236
+ let markdownPath = options.markdownAlternates === !1 ? void 0 : artifactManifest.byHtmlPath[page.path];
237
+ return {
238
+ title: page.title,
239
+ url: canonicalUrl(manifest, page.path, page.group),
240
+ ...markdownPath ? {
241
+ alternate: {
242
+ title: "Markdown",
243
+ url: canonicalUrl(manifest, markdownPath, page.group)
244
+ }
245
+ } : {}
246
+ };
247
+ })
248
+ };
249
+ })
250
+ ],
251
+ otherGroupLinks: options.otherGroupLinks?.map((link) => ({
252
+ title: link.title,
253
+ url: canonicalUrl(manifest, link.path, link.group)
254
+ }))
71
255
  });
72
- return [
73
- `# ${manifest.site.name} Sitemap`,
74
- "## Agent indexes",
75
- `- [LLMS index](${canonicalUrl(manifest, "/llms.txt")})`,
76
- `- [Full LLMS index](${canonicalUrl(manifest, "/llms-full.txt")})`,
77
- `- [XML sitemap](${canonicalUrl(manifest, "/sitemap.xml")})`,
78
- "## Sections",
79
- groups.length ? groups.join(`
80
- `) : `- [Home](${canonicalUrl(manifest, "/")})`,
81
- "## Pages",
82
- pages.length ? pages.join(`
83
- `) : `- [Home](${canonicalUrl(manifest, "/")})`,
84
- ""
85
- ].join(`
86
-
87
- `);
88
256
  }
89
- function createSitemapMarkdownRoute(manifest, artifactManifest) {
257
+ function createSitemapMarkdownRoute(manifest, artifactManifest, options = {}) {
90
258
  return async function() {
91
259
  return createCachedTextResponse({
92
- body: await sitemapMarkdown(manifest, artifactManifest),
260
+ body: await sitemapMarkdown(manifest, artifactManifest, options),
93
261
  contentType: "text/markdown; charset=utf-8"
94
262
  });
95
263
  };
@@ -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 };