@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
@@ -34,84 +34,244 @@ function createCachedTextResponse(options) {
34
34
  });
35
35
  }
36
36
 
37
+ // src/route-not-found.ts
38
+ var MAX_PATH_LENGTH = 2048, UNSAFE_PATH_CHARACTERS = /[\p{Cc}\p{Cs}\u200b-\u200f\u2028-\u202f\u2060-\u206f\ufeff]/u, INTERNAL_PATHS = ["/__publishos", "/_next", "/_not-found", "/publishos"], DEFAULT_MARKDOWN = serializeNotFoundMarkdown({
39
+ recommendations: [],
40
+ indexes: []
41
+ });
42
+ function normalizePublicPath(pathname) {
43
+ let path = pathname.split(/[?#]/u, 1)[0];
44
+ if (!path?.startsWith("/") || path.startsWith("//") || path.length > MAX_PATH_LENGTH || UNSAFE_PATH_CHARACTERS.test(path))
45
+ return;
46
+ let segments = [];
47
+ for (let segment of path.split("/")) {
48
+ if (!segment) continue;
49
+ let decoded;
50
+ try {
51
+ decoded = decodeURIComponent(segment);
52
+ } catch {
53
+ return;
54
+ }
55
+ if (decoded === "." || decoded === ".." || /[/\\]/u.test(decoded) || /%[\da-f]{2}/iu.test(decoded) || UNSAFE_PATH_CHARACTERS.test(decoded))
56
+ return;
57
+ segments.push(decoded.normalize("NFC"));
58
+ }
59
+ return `/${segments.join("/")}`;
60
+ }
61
+ function containsPath({ parent, path }) {
62
+ return parent === "/" || path === parent || path.startsWith(`${parent}/`);
63
+ }
64
+ function missingPagePath(pathname) {
65
+ let normalized = normalizePublicPath(pathname);
66
+ if (!normalized) return;
67
+ let path = normalized.endsWith(".md") ? normalized.slice(0, -3) || "/" : normalized;
68
+ return INTERNAL_PATHS.some((parent) => containsPath({ parent, path })) ? void 0 : path;
69
+ }
70
+ function resolveNotFoundScope({
71
+ scopes,
72
+ pathname
73
+ }) {
74
+ let path = missingPagePath(pathname);
75
+ if (!path) return;
76
+ let matched, matchedLength = -1;
77
+ for (let scope of scopes) {
78
+ let scopePath = normalizePublicPath(scope.path);
79
+ !scopePath || !containsPath({ parent: scopePath, path }) || (scopePath.length > matchedLength || scopePath.length === matchedLength && scope.group && !matched?.group) && (matched = scope, matchedLength = scopePath.length);
80
+ }
81
+ return matched;
82
+ }
83
+ function trustedHostname(origin) {
84
+ if (origin)
85
+ try {
86
+ let url = new URL(origin);
87
+ return !["http:", "https:"].includes(url.protocol) || url.username || url.password ? void 0 : url.host.replace(/`/gu, "%60");
88
+ } catch {
89
+ return;
90
+ }
91
+ }
92
+ function requestExplanation({
93
+ pathname,
94
+ origin
95
+ }) {
96
+ let path = pathname.split("/").map(encodeURIComponent).join("/"), hostname = trustedHostname(origin);
97
+ return `No page exists at \`${path}\`${hostname ? ` on ${hostname}` : ""}.`;
98
+ }
99
+ function indexKind(link) {
100
+ if (link.kind) return link.kind;
101
+ switch (link.title) {
102
+ case "Sitemap":
103
+ return "sitemap";
104
+ case "Markdown sitemap":
105
+ return "sitemap-md";
106
+ case "llms.txt":
107
+ case "LLMS index":
108
+ return "llms";
109
+ case "llms-full.txt":
110
+ return "llms-full";
111
+ default:
112
+ return;
113
+ }
114
+ }
115
+ function publicRecoveryHref(href) {
116
+ if (href.includes("\\") || UNSAFE_PATH_CHARACTERS.test(href))
117
+ return;
118
+ let relative = href.startsWith("/") && !href.startsWith("//");
119
+ try {
120
+ let url = new URL(
121
+ href,
122
+ relative ? "https://publishos.invalid" : void 0
123
+ );
124
+ return !["http:", "https:"].includes(url.protocol) || url.username || url.password ? void 0 : relative ? `${url.pathname}${url.search}${url.hash}` : url.href;
125
+ } catch {
126
+ return;
127
+ }
128
+ }
129
+ function markdownText(value) {
130
+ return value.replace(/\s+/gu, " ").replace(/[\p{Cc}\p{Cs}]/gu, "").trim().replace(/[\\`*_[\]{}<>|~]/gu, "\\$&");
131
+ }
132
+ function markdownLink(link) {
133
+ let title = markdownText(link.title), href = publicRecoveryHref(link.href)?.replace(
134
+ /[()`<>]/gu,
135
+ (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`
136
+ );
137
+ if (!title || !href) return;
138
+ let description = link.description ? markdownText(link.description) : void 0;
139
+ return `- [${title}](${href})${description ? `: ${description}` : ""}`;
140
+ }
141
+ function serializeNotFoundMarkdown({
142
+ recommendations,
143
+ indexes
144
+ }) {
145
+ let sections = [
146
+ { title: "Recommendations", links: recommendations },
147
+ { title: "For crawlers and agents", links: indexes }
148
+ ], lines = [
149
+ "# 404 \u2014 Not Found",
150
+ "",
151
+ "This page does not exist. Please check the URL and try again.",
152
+ ""
153
+ ];
154
+ for (let section of sections) {
155
+ let links = section.links.map(markdownLink).filter((link) => link !== void 0);
156
+ links.length && lines.push(`## ${section.title}`, "", ...links, "");
157
+ }
158
+ return lines.join(`
159
+ `);
160
+ }
161
+ function discoveryHeaders(scope) {
162
+ let headers = new Headers(), links = [];
163
+ for (let link of scope?.indexes ?? []) {
164
+ let kind = indexKind(link), href = /[\s<>"\\]/u.test(link.href) ? void 0 : publicRecoveryHref(link.href);
165
+ if (!(!kind || !href))
166
+ switch (kind) {
167
+ case "llms":
168
+ if (scope?.describedBy !== void 0) break;
169
+ links.push(`<${href}>; rel="describedby"; type="text/plain"`), headers.set("x-publishos-llms", href);
170
+ break;
171
+ case "llms-full":
172
+ links.push(
173
+ `<${href}>; rel="related"; type="text/plain"; title="Full content"`
174
+ );
175
+ break;
176
+ case "sitemap":
177
+ case "sitemap-md":
178
+ links.push(
179
+ `<${href}>; rel="sitemap"; type="${kind === "sitemap-md" ? "text/markdown" : "application/xml"}"`
180
+ ), headers.set("x-publishos-sitemap", href);
181
+ break;
182
+ }
183
+ }
184
+ if (scope?.describedBy !== void 0) {
185
+ let href = /[\s<>"\\]/u.test(scope.describedBy) ? void 0 : publicRecoveryHref(scope.describedBy);
186
+ href && (links.push(`<${href}>; rel="describedby"; type="text/plain"`), headers.set("x-publishos-llms", href));
187
+ }
188
+ return links.length && headers.set("link", links.join(", ")), headers;
189
+ }
190
+ function createNotFoundTextResponse({
191
+ scope,
192
+ pathname,
193
+ method,
194
+ contentType = "text/markdown; charset=utf-8",
195
+ vary = !1
196
+ }) {
197
+ let path = pathname === void 0 ? void 0 : missingPagePath(pathname), resolvedScope = scope && (pathname === void 0 || resolveNotFoundScope({ scopes: [scope], pathname })) ? scope : void 0, body = resolvedScope?.markdown ?? DEFAULT_MARKDOWN;
198
+ if (resolvedScope && path) {
199
+ let explanation = requestExplanation({
200
+ pathname: path,
201
+ origin: scope?.origin
202
+ }), headingEnd = body.indexOf(`
203
+
204
+ `);
205
+ body = headingEnd === -1 ? `${body}
206
+
207
+ ${explanation}
208
+ ` : `${body.slice(0, headingEnd)}
209
+
210
+ ${explanation}
211
+
212
+ ${body.slice(headingEnd + 2)}`;
213
+ }
214
+ let headers = discoveryHeaders(resolvedScope);
215
+ return vary && headers.set("vary", "Accept, User-Agent"), createCachedTextResponse({
216
+ body,
217
+ cachePolicy: "short",
218
+ contentType,
219
+ headers,
220
+ method,
221
+ noindex: !0,
222
+ status: 404
223
+ });
224
+ }
225
+
37
226
  // src/route-agent-markdown.ts
38
- var DEFAULT_DISCOVERY_LINKS = {
39
- home: "/",
40
- llms: "/llms.txt",
41
- sitemap: "/sitemap.md"
42
- };
43
227
  function debugMarkdownResponse(details) {
44
228
  log.debug("[agent-route]", "md-response", details);
45
229
  }
46
230
  function normalizeArtifactPath(parts) {
47
- return parts?.length ? parts.some((part) => part === ".." || part.includes("\0")) ? null : `/${parts.join("/")}`.replace(/\/+/g, "/") : "/index.md";
231
+ return parts?.length ? parts.some((part) => part === ".." || part.includes("\0")) ? null : `/${parts.join("/")}`.replace(/\/+/g, "/").normalize("NFC") : "/index.md";
48
232
  }
49
233
  function findArtifactKey(artifacts, artifactPath) {
50
- if (artifacts[artifactPath]) return artifactPath;
51
- let suffixedPath = artifactPath.endsWith(".md") ? artifactPath : `${artifactPath}.md`;
52
- if (artifacts[suffixedPath]) return suffixedPath;
234
+ let suffixedPath = `${artifactPath}.md`;
235
+ return artifacts[suffixedPath] ? suffixedPath : artifacts[artifactPath] ? artifactPath : void 0;
53
236
  }
54
237
  function findArtifact(artifacts, artifactPath) {
55
- return artifacts[artifactPath] ?? artifacts[artifactPath.endsWith(".md") ? artifactPath : `${artifactPath}.md`];
238
+ return artifacts[artifactPath] ?? artifacts[`${artifactPath}.md`];
56
239
  }
57
240
  function markdownHeaders(artifact) {
241
+ let robots = [
242
+ artifact.robots?.index === void 0 ? void 0 : artifact.robots.index ? "index" : "noindex",
243
+ artifact.robots?.follow === void 0 ? void 0 : artifact.robots.follow ? "follow" : "nofollow"
244
+ ].filter(Boolean).join(", ");
58
245
  return {
59
246
  headers: {
60
- link: `<${artifact.markdownPath}>; rel="alternate"; type="text/markdown", </llms.txt>; rel="llms-txt"; type="text/plain"`
247
+ link: `<${new URL(artifact.markdownPath, "https://publish.invalid").pathname}>; rel="alternate"; type="text/markdown", </llms.txt>; rel="llms-txt"; type="text/plain"`,
248
+ ...robots ? { "x-robots-tag": robots } : {}
61
249
  },
62
250
  contentType: "text/markdown; charset=utf-8"
63
251
  };
64
252
  }
65
- function markdown404Body(discoveryLinks) {
66
- return [
67
- "# Not found",
68
- "",
69
- ...[
70
- discoveryLinks.home ? `> Home: ${discoveryLinks.home}` : void 0,
71
- discoveryLinks.sitemap ? `> Sitemap: ${discoveryLinks.sitemap}` : void 0,
72
- discoveryLinks.llms ? `> LLMS index: ${discoveryLinks.llms}` : void 0
73
- ].filter((line) => !!line),
74
- "",
75
- "The requested Markdown page was not found.",
76
- ""
77
- ].join(`
78
- `);
79
- }
80
- function notFoundResponse(method, discoveryLinks, artifactPath, reason) {
253
+ function notFoundResponse(method, scopes, artifactPath, reason) {
81
254
  return debugMarkdownResponse({
82
255
  artifactPath,
83
256
  method,
84
257
  reason,
85
258
  status: 404
86
- }), createCachedTextResponse({
87
- body: markdown404Body(discoveryLinks),
88
- cachePolicy: "short",
89
- contentType: "text/markdown; charset=utf-8",
90
- method,
91
- noindex: !0,
92
- status: 404
259
+ }), createNotFoundTextResponse({
260
+ scope: artifactPath ? resolveNotFoundScope({ scopes, pathname: artifactPath }) : void 0,
261
+ pathname: artifactPath,
262
+ method
93
263
  });
94
264
  }
95
- async function markdownResponse(artifacts, discoveryLinks, method, context) {
265
+ async function markdownResponse(artifacts, scopes, method, context) {
96
266
  let params = await Promise.resolve(context.params), artifactPath = normalizeArtifactPath(params?.path);
97
267
  if (!artifactPath)
98
- return notFoundResponse(method, discoveryLinks, void 0, "invalid-path");
268
+ return notFoundResponse(method, scopes, void 0, "invalid-path");
99
269
  let artifactKey = findArtifactKey(artifacts.index, artifactPath);
100
270
  if (!artifactKey)
101
- return notFoundResponse(
102
- method,
103
- discoveryLinks,
104
- artifactPath,
105
- "missing-index"
106
- );
271
+ return notFoundResponse(method, scopes, artifactPath, "missing-index");
107
272
  let artifact = await artifacts.loadArtifact(artifactKey);
108
273
  if (!artifact)
109
- return notFoundResponse(
110
- method,
111
- discoveryLinks,
112
- artifactPath,
113
- "missing-shard"
114
- );
274
+ return notFoundResponse(method, scopes, artifactPath, "missing-shard");
115
275
  let { contentType, headers } = markdownHeaders(artifact);
116
276
  return debugMarkdownResponse({
117
277
  artifactPath: artifact.markdownPath,
@@ -127,13 +287,28 @@ async function markdownResponse(artifacts, discoveryLinks, method, context) {
127
287
  });
128
288
  }
129
289
  function createMarkdownRouteHandlers(artifacts, options = {}) {
130
- let discoveryLinks = {
131
- ...DEFAULT_DISCOVERY_LINKS,
132
- ...options.discoveryLinks
133
- };
290
+ let links = options.discoveryLinks, recommendations = links?.home ? [{ title: "Go home", href: links.home }] : [], indexes = [
291
+ ...links?.sitemap ? [
292
+ {
293
+ title: "Markdown sitemap",
294
+ href: links.sitemap,
295
+ kind: "sitemap-md"
296
+ }
297
+ ] : [],
298
+ ...links?.llms ? [{ title: "llms.txt", href: links.llms, kind: "llms" }] : []
299
+ ], scopes = options.notFoundScopes ?? (links ? [
300
+ {
301
+ id: "root",
302
+ path: "/",
303
+ htmlPath: "",
304
+ recommendations,
305
+ indexes,
306
+ markdown: serializeNotFoundMarkdown({ recommendations, indexes })
307
+ }
308
+ ] : []);
134
309
  return {
135
- GET: (_request, context) => markdownResponse(artifacts, discoveryLinks, "GET", context),
136
- HEAD: (_request, context) => markdownResponse(artifacts, discoveryLinks, "HEAD", context),
310
+ GET: (_request, context) => markdownResponse(artifacts, scopes, "GET", context),
311
+ HEAD: (_request, context) => markdownResponse(artifacts, scopes, "HEAD", context),
137
312
  generateStaticParams: () => Object.keys(artifacts.index).map((artifactPath) => ({
138
313
  path: artifactPath.replace(/^\//, "").replace(/\.md$/, "").split("/")
139
314
  }))
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ReactElement, ReactNode } from 'react';
3
- import { M as ManifestLike, L as LayoutProps } from '../../../types-BzkZty3r.js';
3
+ import { M as ManifestLike, L as LayoutProps } from '../../../types-BbqmOzLC.js';
4
4
 
5
5
  type LayoutComponent = (props: LayoutProps) => ReactElement | Promise<ReactElement>;
6
6
  type GroupLayoutConfig = {
@@ -21,8 +21,8 @@ var isDev = process.env.NODE_ENV !== "production", isDebugEnabled = process.env.
21
21
  };
22
22
 
23
23
  // src/route-layout-group.tsx
24
- import { jsx } from "react/jsx-runtime";
25
- var manifests = /* @__PURE__ */ new Map(), layoutChains = /* @__PURE__ */ new Map();
24
+ import { jsx } from "@publish.os/nextjs/jsx-runtime";
25
+ var manifests = /* @__PURE__ */ new Map();
26
26
  async function CachedGroupLayoutData({
27
27
  routeGroup,
28
28
  layoutGroup
@@ -39,12 +39,10 @@ function createGroupLayout({
39
39
  manifest,
40
40
  layouts
41
41
  }) {
42
- return manifests.set(group, manifest), layoutChains.set(group, layouts), async function({ children }) {
43
- log.debug("[render]", `${group}/layout`);
44
- let chain = layoutChains.get(group);
45
- chain?.length || notFound();
42
+ return manifests.set(group, manifest), async function({ children }) {
43
+ log.debug("[render]", `${group}/layout`), layouts.length || notFound();
46
44
  let resolvedLayouts = await Promise.all(
47
- chain.map(async (item) => ({
45
+ layouts.map(async (item) => ({
48
46
  item,
49
47
  props: await CachedGroupLayoutData({
50
48
  layoutGroup: item.group,
@@ -1,11 +1,10 @@
1
- import { P as PageStatus, M as ManifestLike } from '../../../types-BzkZty3r.js';
1
+ import { M as ManifestLike } from '../../../types-BbqmOzLC.js';
2
2
 
3
3
  type FeedScope = "site" | "group" | "self";
4
4
  type FeedRouteOptions = {
5
5
  scope?: FeedScope;
6
6
  group?: string;
7
7
  limit?: number;
8
- status?: PageStatus[];
9
8
  };
10
9
  type PrecomputedFeedOutput = {
11
10
  body: string;
@@ -2,10 +2,22 @@
2
2
  import { tags } from "@publish.os/nextjs/cache/tags";
3
3
  import { cacheLife, cacheTag } from "next/cache";
4
4
 
5
+ // src/lib/runtime/metadata/authored-date.ts
6
+ function authoredDate(value) {
7
+ if (typeof value != "string" || !/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2}))?$/.test(
8
+ value
9
+ ))
10
+ return;
11
+ let day = value.slice(0, 10), midnight = /* @__PURE__ */ new Date(`${day}T00:00:00.000Z`);
12
+ if (!(!Number.isFinite(midnight.getTime()) || midnight.toISOString().slice(0, 10) !== day))
13
+ return Number.isFinite(Date.parse(value)) ? value : void 0;
14
+ }
15
+
5
16
  // src/lib/runtime/metadata/canonical-url.ts
6
17
  function canonicalUrl(manifest, path, group) {
7
18
  let origin = (group && manifest.groups[group]?.origin) ?? manifest.site.origin;
8
- if (!origin) return path;
19
+ if (!origin)
20
+ return /^[a-z][a-z\d+.-]*:/i.test(path) ? path : new URL(path, "https://publish.invalid").pathname;
9
21
  try {
10
22
  return new URL(path, `${origin}/`).toString();
11
23
  } catch {
@@ -13,6 +25,84 @@ function canonicalUrl(manifest, path, group) {
13
25
  }
14
26
  }
15
27
 
28
+ // src/lib/runtime/metadata/feed-serialization.ts
29
+ var siteBuildTime = process.env.PUBLISHOS_SITE_BUILD_TIME ?? (/* @__PURE__ */ new Date()).toISOString();
30
+ function xmlEscape(value) {
31
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
32
+ }
33
+ function serializeRssFeed(input) {
34
+ let description = input.description ?? input.title, items = input.pages.map((page) => {
35
+ let publishedAt = page.publishedAt, pubDate = publishedAt ? `
36
+ <pubDate>${xmlEscape(new Date(publishedAt).toUTCString())}</pubDate>` : "", itemDescription = page.description ? `
37
+ <description>${xmlEscape(page.description)}</description>` : "";
38
+ return ` <item>
39
+ <title>${xmlEscape(page.title)}</title>
40
+ <link>${xmlEscape(page.url)}</link>
41
+ <guid>${xmlEscape(page.url)}</guid>${pubDate}${itemDescription}
42
+ </item>`;
43
+ }).join(`
44
+ `);
45
+ return `<?xml version="1.0" encoding="UTF-8"?>
46
+ <rss version="2.0">
47
+ <channel>
48
+ <title>${xmlEscape(input.title)}</title>
49
+ <link>${xmlEscape(input.homeUrl)}</link>
50
+ <description>${xmlEscape(description)}</description>
51
+ ${items}
52
+ </channel>
53
+ </rss>
54
+ `;
55
+ }
56
+ function serializeAtomFeed(input) {
57
+ let buildTime = input.buildTime ?? siteBuildTime, effectiveDates = input.pages.map(
58
+ (page) => new Date(page.updatedAt ?? page.publishedAt ?? buildTime).toISOString()
59
+ ), entries = input.pages.map((page, index) => {
60
+ let updated = effectiveDates[index] ?? buildTime, summary = page.description ? `
61
+ <summary>${xmlEscape(page.description)}</summary>` : "";
62
+ return ` <entry>
63
+ <title>${xmlEscape(page.title)}</title>
64
+ <id>${xmlEscape(page.url)}</id>
65
+ <link href="${xmlEscape(page.url)}" />
66
+ <updated>${xmlEscape(updated)}</updated>${summary}
67
+ </entry>`;
68
+ }).join(`
69
+ `), latest = effectiveDates.length ? new Date(
70
+ Math.max(...effectiveDates.map((date) => Date.parse(date)))
71
+ ).toISOString() : buildTime;
72
+ return `<?xml version="1.0" encoding="UTF-8"?>
73
+ <feed xmlns="http://www.w3.org/2005/Atom">
74
+ <title>${xmlEscape(input.title)}</title>
75
+ <id>${xmlEscape(input.homeUrl)}</id>
76
+ <author><name>${xmlEscape(input.author ?? input.title)}</name></author>
77
+ <updated>${xmlEscape(latest)}</updated>
78
+ ${entries}
79
+ </feed>
80
+ `;
81
+ }
82
+ function serializeJsonFeed(input) {
83
+ return `${JSON.stringify(
84
+ {
85
+ version: "https://jsonfeed.org/version/1.1",
86
+ title: input.title,
87
+ description: input.description,
88
+ home_page_url: input.homeUrl,
89
+ items: input.pages.map((page) => ({
90
+ id: page.url,
91
+ url: page.url,
92
+ title: page.title,
93
+ summary: page.description,
94
+ content_text: page.body,
95
+ date_published: page.publishedAt ? new Date(page.publishedAt).toISOString() : void 0,
96
+ date_modified: page.updatedAt ? new Date(page.updatedAt).toISOString() : void 0,
97
+ tags: page.tags
98
+ }))
99
+ },
100
+ null,
101
+ 2
102
+ )}
103
+ `;
104
+ }
105
+
16
106
  // src/lib/runtime/response/cached-text-response.ts
17
107
  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
108
  function cacheControl(policy) {
@@ -34,119 +124,60 @@ function createCachedTextResponse(options) {
34
124
  }
35
125
 
36
126
  // src/route-metadata-feed.ts
37
- function xmlEscape(value) {
38
- return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
39
- }
40
127
  function pageTimestamp(page) {
41
- let value = pageDate(page);
128
+ let value = authoredDate(page.frontmatter.publishedAt) ?? authoredDate(page.frontmatter.updatedAt);
42
129
  return value ? Date.parse(value) : -1 / 0;
43
130
  }
44
- function validDate(value) {
45
- return value && !Number.isNaN(Date.parse(value)) ? value : void 0;
46
- }
47
131
  function pageInScope(page, options) {
48
132
  return options.scope === "site" || !options.group ? !0 : options.scope === "self" ? page.group === options.group : page.group === options.group || page.group.startsWith(`${options.group}/`);
49
133
  }
50
134
  function feedPages(manifest, options) {
51
- let statuses = options.status ?? ["published"], pages = manifest.pages.filter((page) => statuses.includes(page.status)).filter((page) => pageInScope(page, options)).sort((a, b) => pageTimestamp(b) - pageTimestamp(a));
135
+ let pages = manifest.pages.filter((page) => page.frontmatter.status === "published").filter((page) => pageInScope(page, options)).sort((a, b) => pageTimestamp(b) - pageTimestamp(a));
52
136
  return options.limit ? pages.slice(0, options.limit) : pages;
53
137
  }
138
+ function feedInput(manifest, options = {}) {
139
+ let serializedPages = feedPages(manifest, options).map((page) => ({
140
+ url: canonicalUrl(manifest, page.path, page.group),
141
+ title: page.frontmatter.title,
142
+ publishedAt: authoredDate(page.frontmatter.publishedAt),
143
+ updatedAt: authoredDate(page.frontmatter.updatedAt),
144
+ description: page.frontmatter.description,
145
+ body: page.body,
146
+ tags: Array.isArray(page.frontmatter.tags) ? page.frontmatter.tags.filter(
147
+ (tag) => typeof tag == "string"
148
+ ) : []
149
+ })), group = options.group, homePath = group ? manifest.groups[group]?.path ?? "/" : "/";
150
+ return {
151
+ // Public route factories use the site name; generated group feeds use the group title.
152
+ title: manifest.site.name,
153
+ description: manifest.site.description,
154
+ homeUrl: canonicalUrl(manifest, homePath, group),
155
+ pages: serializedPages
156
+ };
157
+ }
54
158
  async function rssXml(manifest, options = {}) {
55
159
  "use cache";
56
- cacheLife("page"), cacheTag(
160
+ return cacheLife("page"), cacheTag(
57
161
  tags.site(),
58
162
  tags.feed("rss", options.group ?? options.scope ?? "site"),
59
163
  tags.manifest(manifest.contentHash)
60
- );
61
- let title = manifest.site.name, description = manifest.site.description ?? title, pages = feedPages(manifest, options), group = options.group, homePath = group ? manifest.groups[group]?.path ?? "/" : "/", homeUrl = canonicalUrl(manifest, homePath, group), items = pages.map((page) => {
62
- let pageUrl = canonicalUrl(manifest, page.path, page.group), publishedAt = validDate(page.publishedAt), pubDate = publishedAt ? `
63
- <pubDate>${xmlEscape(new Date(publishedAt).toUTCString())}</pubDate>` : "", description2 = page.description ? `
64
- <description>${xmlEscape(page.description)}</description>` : "";
65
- return ` <item>
66
- <title>${xmlEscape(page.title)}</title>
67
- <link>${xmlEscape(pageUrl)}</link>
68
- <guid>${xmlEscape(pageUrl)}</guid>${pubDate}${description2}
69
- </item>`;
70
- }).join(`
71
- `);
72
- return `<?xml version="1.0" encoding="UTF-8"?>
73
- <rss version="2.0">
74
- <channel>
75
- <title>${xmlEscape(title)}</title>
76
- <link>${xmlEscape(homeUrl)}</link>
77
- <description>${xmlEscape(description)}</description>
78
- ${items}
79
- </channel>
80
- </rss>
81
- `;
82
- }
83
- function pageDate(page) {
84
- return validDate(page.publishedAt) ?? validDate(page.updatedAt);
85
- }
86
- function latestFeedDate(pages) {
87
- let timestamp = Math.max(0, ...pages.map((page) => pageTimestamp(page)));
88
- return new Date(timestamp).toISOString();
164
+ ), serializeRssFeed(feedInput(manifest, options));
89
165
  }
90
166
  async function atomXml(manifest, options = {}) {
91
167
  "use cache";
92
- cacheLife("page"), cacheTag(
168
+ return cacheLife("page"), cacheTag(
93
169
  tags.site(),
94
170
  tags.feed("atom", options.group ?? options.scope ?? "site"),
95
171
  tags.manifest(manifest.contentHash)
96
- );
97
- let title = manifest.site.name, pages = feedPages(manifest, options), group = options.group, homePath = group ? manifest.groups[group]?.path ?? "/" : "/", homeUrl = canonicalUrl(manifest, homePath, group), entries = pages.map((page) => {
98
- let date = pageDate(page), updated = date ? new Date(date).toISOString() : latestFeedDate([]), pageUrl = canonicalUrl(manifest, page.path, page.group), summary = page.description ? `
99
- <summary>${xmlEscape(page.description)}</summary>` : "";
100
- return ` <entry>
101
- <title>${xmlEscape(page.title)}</title>
102
- <id>${xmlEscape(pageUrl)}</id>
103
- <link href="${xmlEscape(pageUrl)}" />
104
- <updated>${xmlEscape(updated)}</updated>${summary}
105
- </entry>`;
106
- }).join(`
107
- `);
108
- return `<?xml version="1.0" encoding="UTF-8"?>
109
- <feed xmlns="http://www.w3.org/2005/Atom">
110
- <title>${xmlEscape(title)}</title>
111
- <id>${xmlEscape(homeUrl)}</id>
112
- <updated>${xmlEscape(latestFeedDate(pages))}</updated>
113
- ${entries}
114
- </feed>
115
- `;
172
+ ), serializeAtomFeed(feedInput(manifest, options));
116
173
  }
117
174
  async function jsonFeed(manifest, options = {}) {
118
175
  "use cache";
119
- cacheLife("page"), cacheTag(
176
+ return cacheLife("page"), cacheTag(
120
177
  tags.site(),
121
178
  tags.feed("json", options.group ?? options.scope ?? "site"),
122
179
  tags.manifest(manifest.contentHash)
123
- );
124
- let pages = feedPages(manifest, options);
125
- return `${JSON.stringify(
126
- {
127
- version: "https://jsonfeed.org/version/1.1",
128
- title: manifest.site.name,
129
- description: manifest.site.description,
130
- home_page_url: canonicalUrl(
131
- manifest,
132
- options.group ? manifest.groups[options.group]?.path ?? "/" : "/",
133
- options.group
134
- ),
135
- items: pages.map((page) => ({
136
- id: canonicalUrl(manifest, page.path, page.group),
137
- url: canonicalUrl(manifest, page.path, page.group),
138
- title: page.title,
139
- summary: page.description,
140
- content_text: page.body,
141
- date_published: validDate(page.publishedAt),
142
- date_modified: validDate(page.updatedAt),
143
- tags: page.tags
144
- }))
145
- },
146
- null,
147
- 2
148
- )}
149
- `;
180
+ ), serializeJsonFeed(feedInput(manifest, options));
150
181
  }
151
182
  function createRssFeedRoute(manifest, options = {}) {
152
183
  return async function() {
@@ -1,26 +1,6 @@
1
- import { MarkdownRouteArtifacts } from '../agent/markdown.js';
2
- import { M as ManifestLike } from '../../../types-BzkZty3r.js';
3
-
4
- type LlmsRouteOptions = {
5
- scope?: "site" | "group" | "self";
6
- group?: string;
7
- limit?: number;
8
- includeDescriptions?: boolean;
9
- links?: Array<{
10
- title: string;
11
- path: string;
12
- group?: string;
13
- }>;
14
- };
15
- type LlmsFullRouteOptions = {
16
- maxBytes?: number;
17
- };
18
- type PrecomputedLlmsTxtOutput = {
1
+ type LlmsTxtOutput = {
19
2
  body: string;
20
3
  };
21
- declare function createLlmsTxtRoute(manifest: ManifestLike, options?: LlmsRouteOptions): () => Promise<Response>;
22
- declare function createPrecomputedLlmsTxtRoute(output: PrecomputedLlmsTxtOutput): () => Response;
23
- declare function llmsFullTxtResponse(manifest: ManifestLike, artifacts: MarkdownRouteArtifacts, options?: LlmsFullRouteOptions): Promise<Response>;
24
- declare function createLlmsFullTxtRoute(manifest: ManifestLike, artifacts: MarkdownRouteArtifacts, options?: LlmsFullRouteOptions): () => Promise<Response>;
4
+ declare function createLlmsTxtRoute(output: LlmsTxtOutput): () => Response;
25
5
 
26
- export { type LlmsFullRouteOptions, type LlmsRouteOptions, type PrecomputedLlmsTxtOutput, createLlmsFullTxtRoute, createLlmsTxtRoute, createPrecomputedLlmsTxtRoute, llmsFullTxtResponse };
6
+ export { type LlmsTxtOutput, createLlmsTxtRoute };