@conloca/astro-cms 0.1.16 → 0.2.1

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 (422) hide show
  1. package/README.md +254 -301
  2. package/dist/internal/acorn-default.mjs +11 -3
  3. package/dist/internal/page-handler.astro +137 -358
  4. package/dist/ts/node/content.d.ts +4 -0
  5. package/dist/ts/node/content.d.ts.map +1 -0
  6. package/dist/ts/node/content.js +3 -0
  7. package/dist/ts/node/content.js.map +1 -0
  8. package/dist/ts/node/index.d.ts +9 -0
  9. package/dist/ts/node/index.d.ts.map +1 -0
  10. package/dist/ts/node/index.js +14 -0
  11. package/dist/ts/node/index.js.map +1 -0
  12. package/dist/ts/src/asset-ref-base.d.ts +3 -0
  13. package/dist/ts/src/asset-ref-base.d.ts.map +1 -0
  14. package/dist/ts/src/asset-ref-base.js +48 -0
  15. package/dist/ts/src/asset-ref-base.js.map +1 -0
  16. package/dist/ts/src/checks.d.ts +7 -0
  17. package/dist/ts/src/checks.d.ts.map +1 -0
  18. package/dist/ts/src/checks.js +7 -0
  19. package/dist/ts/src/checks.js.map +1 -0
  20. package/dist/{src → ts/src}/cms-handler.d.ts +0 -1
  21. package/dist/ts/src/cms-handler.d.ts.map +1 -0
  22. package/dist/{src → ts/src}/cms-handler.js +11 -131
  23. package/dist/ts/src/cms-handler.js.map +1 -0
  24. package/dist/ts/src/collections.d.ts +161 -0
  25. package/dist/ts/src/collections.d.ts.map +1 -0
  26. package/dist/ts/src/collections.js +178 -0
  27. package/dist/ts/src/collections.js.map +1 -0
  28. package/dist/{src → ts/src}/components/HydrationWrapper.d.ts +1 -1
  29. package/dist/ts/src/components/HydrationWrapper.d.ts.map +1 -0
  30. package/dist/{src → ts/src}/components/HydrationWrapper.js +1 -0
  31. package/dist/ts/src/components/HydrationWrapper.js.map +1 -0
  32. package/dist/{src/components/RenderWithBlocks.d.ts → ts/src/components/RenderWithFragments.d.ts} +8 -4
  33. package/dist/ts/src/components/RenderWithFragments.d.ts.map +1 -0
  34. package/dist/ts/src/components/RenderWithFragments.js +133 -0
  35. package/dist/ts/src/components/RenderWithFragments.js.map +1 -0
  36. package/dist/{src → ts/src}/components/RenderWithHydration.d.ts +6 -2
  37. package/dist/ts/src/components/RenderWithHydration.d.ts.map +1 -0
  38. package/dist/{src → ts/src}/components/RenderWithHydration.js +6 -3
  39. package/dist/ts/src/components/RenderWithHydration.js.map +1 -0
  40. package/dist/ts/src/components.d.ts +4 -0
  41. package/dist/ts/src/components.d.ts.map +1 -0
  42. package/dist/ts/src/components.js +4 -0
  43. package/dist/ts/src/components.js.map +1 -0
  44. package/dist/ts/src/discovery/astro-frontmatter.d.ts.map +1 -0
  45. package/dist/{src → ts/src}/discovery/astro-frontmatter.js +1 -0
  46. package/dist/ts/src/discovery/astro-frontmatter.js.map +1 -0
  47. package/dist/ts/src/discovery/discover.d.ts +43 -0
  48. package/dist/ts/src/discovery/discover.d.ts.map +1 -0
  49. package/dist/ts/src/discovery/discover.js +87 -0
  50. package/dist/ts/src/discovery/discover.js.map +1 -0
  51. package/dist/ts/src/discovery/extract-props-ts.d.ts.map +1 -0
  52. package/dist/{src → ts/src}/discovery/extract-props-ts.js +1 -0
  53. package/dist/ts/src/discovery/extract-props-ts.js.map +1 -0
  54. package/dist/{src → ts/src}/discovery/merge-registry.d.ts +3 -3
  55. package/dist/ts/src/discovery/merge-registry.d.ts.map +1 -0
  56. package/dist/{src → ts/src}/discovery/merge-registry.js +1 -0
  57. package/dist/ts/src/discovery/merge-registry.js.map +1 -0
  58. package/dist/ts/src/discovery/registry-endpoint.d.ts +27 -0
  59. package/dist/ts/src/discovery/registry-endpoint.d.ts.map +1 -0
  60. package/dist/ts/src/discovery/registry-endpoint.js +76 -0
  61. package/dist/ts/src/discovery/registry-endpoint.js.map +1 -0
  62. package/dist/{src → ts/src}/discovery/scan-components.d.ts +3 -7
  63. package/dist/ts/src/discovery/scan-components.d.ts.map +1 -0
  64. package/dist/{src → ts/src}/discovery/scan-components.js +4 -6
  65. package/dist/ts/src/discovery/scan-components.js.map +1 -0
  66. package/dist/ts/src/discovery/scan-mdx.d.ts.map +1 -0
  67. package/dist/{src → ts/src}/discovery/scan-mdx.js +1 -0
  68. package/dist/ts/src/discovery/scan-mdx.js.map +1 -0
  69. package/dist/ts/src/discovery/scan-overrides.d.ts.map +1 -0
  70. package/dist/{src → ts/src}/discovery/scan-overrides.js +1 -0
  71. package/dist/ts/src/discovery/scan-overrides.js.map +1 -0
  72. package/dist/ts/src/editor-descriptors.d.ts +31 -0
  73. package/dist/ts/src/editor-descriptors.d.ts.map +1 -0
  74. package/dist/ts/src/editor-descriptors.js +84 -0
  75. package/dist/ts/src/editor-descriptors.js.map +1 -0
  76. package/dist/ts/src/handlers/collection-content-api.d.ts +32 -0
  77. package/dist/ts/src/handlers/collection-content-api.d.ts.map +1 -0
  78. package/dist/ts/src/handlers/collection-content-api.js +166 -0
  79. package/dist/ts/src/handlers/collection-content-api.js.map +1 -0
  80. package/dist/ts/src/handlers/page-render-core.d.ts +137 -0
  81. package/dist/ts/src/handlers/page-render-core.d.ts.map +1 -0
  82. package/dist/ts/src/handlers/page-render-core.js +315 -0
  83. package/dist/ts/src/handlers/page-render-core.js.map +1 -0
  84. package/dist/ts/src/hydration.d.ts.map +1 -0
  85. package/dist/{src → ts/src}/hydration.js +1 -0
  86. package/dist/ts/src/hydration.js.map +1 -0
  87. package/dist/ts/src/index.d.ts +21 -0
  88. package/dist/ts/src/index.d.ts.map +1 -0
  89. package/dist/ts/src/index.js +45 -0
  90. package/dist/ts/src/index.js.map +1 -0
  91. package/dist/ts/src/internal/declared-collections.d.ts +30 -0
  92. package/dist/ts/src/internal/declared-collections.d.ts.map +1 -0
  93. package/dist/ts/src/internal/declared-collections.js +84 -0
  94. package/dist/ts/src/internal/declared-collections.js.map +1 -0
  95. package/dist/ts/src/internal/page-collection-schema.d.ts +44 -0
  96. package/dist/ts/src/internal/page-collection-schema.d.ts.map +1 -0
  97. package/dist/ts/src/internal/page-collection-schema.js +152 -0
  98. package/dist/ts/src/internal/page-collection-schema.js.map +1 -0
  99. package/dist/ts/src/lib/content-config-guard.d.ts +13 -0
  100. package/dist/ts/src/lib/content-config-guard.d.ts.map +1 -0
  101. package/dist/ts/src/lib/content-config-guard.js +45 -0
  102. package/dist/ts/src/lib/content-config-guard.js.map +1 -0
  103. package/dist/ts/src/lib/hydration-scanner.d.ts.map +1 -0
  104. package/dist/{src → ts/src}/lib/hydration-scanner.js +1 -0
  105. package/dist/ts/src/lib/hydration-scanner.js.map +1 -0
  106. package/dist/ts/src/lib/hydration-script.d.ts.map +1 -0
  107. package/dist/{src → ts/src}/lib/hydration-script.js +1 -0
  108. package/dist/ts/src/lib/hydration-script.js.map +1 -0
  109. package/dist/ts/src/lib/hydration-utils.d.ts.map +1 -0
  110. package/dist/{src → ts/src}/lib/hydration-utils.js +1 -0
  111. package/dist/ts/src/lib/hydration-utils.js.map +1 -0
  112. package/dist/ts/src/lib/resolve-locale.d.ts +15 -0
  113. package/dist/ts/src/lib/resolve-locale.d.ts.map +1 -0
  114. package/dist/ts/src/lib/resolve-locale.js +16 -0
  115. package/dist/ts/src/lib/resolve-locale.js.map +1 -0
  116. package/dist/ts/src/lib/resolve-site-name.d.ts +8 -0
  117. package/dist/ts/src/lib/resolve-site-name.d.ts.map +1 -0
  118. package/dist/ts/src/lib/resolve-site-name.js +12 -0
  119. package/dist/ts/src/lib/resolve-site-name.js.map +1 -0
  120. package/dist/{src → ts/src}/lib/route-utils.d.ts +26 -6
  121. package/dist/ts/src/lib/route-utils.d.ts.map +1 -0
  122. package/dist/{src → ts/src}/lib/route-utils.js +33 -15
  123. package/dist/ts/src/lib/route-utils.js.map +1 -0
  124. package/dist/{src → ts/src}/lib/routing-config.d.ts +7 -1
  125. package/dist/ts/src/lib/routing-config.d.ts.map +1 -0
  126. package/dist/{src → ts/src}/lib/routing-config.js +13 -0
  127. package/dist/ts/src/lib/routing-config.js.map +1 -0
  128. package/dist/ts/src/lib/serialize-props.d.ts.map +1 -0
  129. package/dist/{src → ts/src}/lib/serialize-props.js +1 -0
  130. package/dist/ts/src/lib/serialize-props.js.map +1 -0
  131. package/dist/ts/src/lib/unknown-components.d.ts +21 -0
  132. package/dist/ts/src/lib/unknown-components.d.ts.map +1 -0
  133. package/dist/ts/src/lib/unknown-components.js +49 -0
  134. package/dist/ts/src/lib/unknown-components.js.map +1 -0
  135. package/dist/{src → ts/src}/lib/virtual-module-generators.d.ts +0 -24
  136. package/dist/ts/src/lib/virtual-module-generators.d.ts.map +1 -0
  137. package/dist/ts/src/lib/virtual-module-generators.js +51 -0
  138. package/dist/ts/src/lib/virtual-module-generators.js.map +1 -0
  139. package/dist/ts/src/lib/withHydration.d.ts.map +1 -0
  140. package/dist/{src → ts/src}/lib/withHydration.js +1 -0
  141. package/dist/ts/src/lib/withHydration.js.map +1 -0
  142. package/dist/ts/src/loader.d.ts +27 -0
  143. package/dist/ts/src/loader.d.ts.map +1 -0
  144. package/dist/{src → ts/src}/loader.js +33 -4
  145. package/dist/ts/src/loader.js.map +1 -0
  146. package/dist/ts/src/locales-helpers.d.ts.map +1 -0
  147. package/dist/{src → ts/src}/locales-helpers.js +1 -0
  148. package/dist/ts/src/locales-helpers.js.map +1 -0
  149. package/dist/ts/src/mime-types.d.ts.map +1 -0
  150. package/dist/{src → ts/src}/mime-types.js +1 -0
  151. package/dist/ts/src/mime-types.js.map +1 -0
  152. package/dist/ts/src/page-feed.d.ts +13 -0
  153. package/dist/ts/src/page-feed.d.ts.map +1 -0
  154. package/dist/ts/src/page-feed.js +20 -0
  155. package/dist/ts/src/page-feed.js.map +1 -0
  156. package/dist/ts/src/page-schemas.d.ts +6 -0
  157. package/dist/ts/src/page-schemas.d.ts.map +1 -0
  158. package/dist/ts/src/page-schemas.js +6 -0
  159. package/dist/ts/src/page-schemas.js.map +1 -0
  160. package/dist/ts/src/path-validation.d.ts.map +1 -0
  161. package/dist/{src → ts/src}/path-validation.js +1 -0
  162. package/dist/ts/src/path-validation.js.map +1 -0
  163. package/dist/{src → ts/src}/plugin-spa.d.ts +28 -10
  164. package/dist/ts/src/plugin-spa.d.ts.map +1 -0
  165. package/dist/{src → ts/src}/plugin-spa.js +301 -88
  166. package/dist/ts/src/plugin-spa.js.map +1 -0
  167. package/dist/ts/src/puck-manifest/components-endpoint.d.ts +30 -0
  168. package/dist/ts/src/puck-manifest/components-endpoint.d.ts.map +1 -0
  169. package/dist/ts/src/puck-manifest/components-endpoint.js +54 -0
  170. package/dist/ts/src/puck-manifest/components-endpoint.js.map +1 -0
  171. package/dist/ts/src/puck-manifest/field-projection.d.ts +91 -0
  172. package/dist/ts/src/puck-manifest/field-projection.d.ts.map +1 -0
  173. package/dist/ts/src/puck-manifest/field-projection.js +422 -0
  174. package/dist/ts/src/puck-manifest/field-projection.js.map +1 -0
  175. package/dist/ts/src/puck-manifest/index.d.ts +4 -0
  176. package/dist/ts/src/puck-manifest/index.d.ts.map +1 -0
  177. package/dist/ts/src/puck-manifest/index.js +3 -0
  178. package/dist/ts/src/puck-manifest/index.js.map +1 -0
  179. package/dist/ts/src/puck-manifest/literal.d.ts +163 -0
  180. package/dist/ts/src/puck-manifest/literal.d.ts.map +1 -0
  181. package/dist/ts/src/puck-manifest/literal.js +354 -0
  182. package/dist/ts/src/puck-manifest/literal.js.map +1 -0
  183. package/dist/ts/src/puck-manifest/read-config.d.ts +42 -0
  184. package/dist/ts/src/puck-manifest/read-config.d.ts.map +1 -0
  185. package/dist/ts/src/puck-manifest/read-config.js +517 -0
  186. package/dist/ts/src/puck-manifest/read-config.js.map +1 -0
  187. package/dist/ts/src/puck-manifest/read-field.d.ts +7 -0
  188. package/dist/ts/src/puck-manifest/read-field.d.ts.map +1 -0
  189. package/dist/ts/src/puck-manifest/read-field.js +11 -0
  190. package/dist/ts/src/puck-manifest/read-field.js.map +1 -0
  191. package/dist/ts/src/puck-manifest/read-wrapper.d.ts +147 -0
  192. package/dist/ts/src/puck-manifest/read-wrapper.d.ts.map +1 -0
  193. package/dist/ts/src/puck-manifest/read-wrapper.js +889 -0
  194. package/dist/ts/src/puck-manifest/read-wrapper.js.map +1 -0
  195. package/dist/ts/src/puck-manifest/reading-budget.d.ts +50 -0
  196. package/dist/ts/src/puck-manifest/reading-budget.d.ts.map +1 -0
  197. package/dist/ts/src/puck-manifest/reading-budget.js +113 -0
  198. package/dist/ts/src/puck-manifest/reading-budget.js.map +1 -0
  199. package/dist/ts/src/puck-manifest/resolve-reference.d.ts +4 -0
  200. package/dist/ts/src/puck-manifest/resolve-reference.d.ts.map +1 -0
  201. package/dist/ts/src/puck-manifest/resolve-reference.js +4 -0
  202. package/dist/ts/src/puck-manifest/resolve-reference.js.map +1 -0
  203. package/dist/ts/src/puck-manifest/source-reference.d.ts +96 -0
  204. package/dist/ts/src/puck-manifest/source-reference.d.ts.map +1 -0
  205. package/dist/ts/src/puck-manifest/source-reference.js +424 -0
  206. package/dist/ts/src/puck-manifest/source-reference.js.map +1 -0
  207. package/dist/ts/src/puck-manifest/syntax.d.ts +29 -0
  208. package/dist/ts/src/puck-manifest/syntax.d.ts.map +1 -0
  209. package/dist/ts/src/puck-manifest/syntax.js +79 -0
  210. package/dist/ts/src/puck-manifest/syntax.js.map +1 -0
  211. package/dist/ts/src/puck-manifest/types.d.ts +145 -0
  212. package/dist/ts/src/puck-manifest/types.d.ts.map +1 -0
  213. package/dist/ts/src/puck-manifest/types.js +2 -0
  214. package/dist/ts/src/puck-manifest/types.js.map +1 -0
  215. package/dist/ts/src/safe-json-stringify.d.ts.map +1 -0
  216. package/dist/{src → ts/src}/safe-json-stringify.js +1 -0
  217. package/dist/ts/src/safe-json-stringify.js.map +1 -0
  218. package/dist/ts/src/sandbox-frame-handler.d.ts +19 -0
  219. package/dist/ts/src/sandbox-frame-handler.d.ts.map +1 -0
  220. package/dist/ts/src/sandbox-frame-handler.js +27 -0
  221. package/dist/ts/src/sandbox-frame-handler.js.map +1 -0
  222. package/dist/{src → ts/src}/site-styles/content-wrapper-endpoint.d.ts +2 -5
  223. package/dist/ts/src/site-styles/content-wrapper-endpoint.d.ts.map +1 -0
  224. package/dist/{src → ts/src}/site-styles/content-wrapper-endpoint.js +5 -8
  225. package/dist/ts/src/site-styles/content-wrapper-endpoint.js.map +1 -0
  226. package/dist/{src → ts/src}/site-styles/render-endpoint.d.ts +4 -9
  227. package/dist/ts/src/site-styles/render-endpoint.d.ts.map +1 -0
  228. package/dist/{src → ts/src}/site-styles/render-endpoint.js +1 -0
  229. package/dist/ts/src/site-styles/render-endpoint.js.map +1 -0
  230. package/dist/{src → ts/src}/site-styles/styles-endpoint.d.ts +2 -4
  231. package/dist/ts/src/site-styles/styles-endpoint.d.ts.map +1 -0
  232. package/dist/{src → ts/src}/site-styles/styles-endpoint.js +3 -5
  233. package/dist/ts/src/site-styles/styles-endpoint.js.map +1 -0
  234. package/dist/ts/src/sitemap-options.d.ts +21 -0
  235. package/dist/ts/src/sitemap-options.d.ts.map +1 -0
  236. package/dist/ts/src/sitemap-options.js +92 -0
  237. package/dist/ts/src/sitemap-options.js.map +1 -0
  238. package/dist/ts/src/tiptap-html-static.d.ts +16 -0
  239. package/dist/ts/src/tiptap-html-static.d.ts.map +1 -0
  240. package/dist/ts/src/tiptap-html-static.js +117 -0
  241. package/dist/ts/src/tiptap-html-static.js.map +1 -0
  242. package/dist/{src → ts/src}/types.d.ts +26 -110
  243. package/dist/ts/src/types.d.ts.map +1 -0
  244. package/dist/ts/src/types.js +2 -0
  245. package/dist/ts/src/types.js.map +1 -0
  246. package/dist/virtual-modules.d.ts +12 -93
  247. package/node/content.ts +14 -0
  248. package/node/index.ts +22 -0
  249. package/package.json +161 -73
  250. package/src/asset-ref-base.ts +48 -0
  251. package/src/checks.ts +11 -0
  252. package/src/cms-handler.ts +281 -0
  253. package/src/collections.ts +271 -0
  254. package/src/components/HydrationWrapper.tsx +41 -0
  255. package/src/components/RenderWithFragments.tsx +204 -0
  256. package/src/components/RenderWithHydration.tsx +55 -0
  257. package/src/components.ts +3 -0
  258. package/src/discovery/astro-frontmatter.ts +24 -0
  259. package/src/discovery/discover.ts +108 -0
  260. package/src/discovery/extract-props-ts.ts +255 -0
  261. package/src/discovery/merge-registry.ts +411 -0
  262. package/src/discovery/registry-endpoint.ts +80 -0
  263. package/src/discovery/scan-components.ts +458 -0
  264. package/src/discovery/scan-mdx.ts +190 -0
  265. package/src/discovery/scan-overrides.ts +92 -0
  266. package/src/editor-descriptors.ts +96 -0
  267. package/src/env.d.ts +31 -0
  268. package/src/handlers/collection-content-api.ts +196 -0
  269. package/src/handlers/page-handler.astro +320 -0
  270. package/src/handlers/page-render-core.ts +456 -0
  271. package/src/hydration.ts +7 -0
  272. package/src/index.ts +111 -0
  273. package/src/internal/acorn-default.mjs +37 -0
  274. package/src/internal/declared-collections.ts +98 -0
  275. package/src/internal/page-collection-schema.ts +210 -0
  276. package/src/lib/content-config-guard.ts +53 -0
  277. package/src/lib/hydration-scanner.ts +176 -0
  278. package/src/lib/hydration-script.ts +126 -0
  279. package/src/lib/hydration-utils.ts +120 -0
  280. package/src/lib/resolve-locale.ts +22 -0
  281. package/src/lib/resolve-site-name.ts +10 -0
  282. package/src/lib/route-utils.ts +106 -0
  283. package/src/lib/routing-config.ts +126 -0
  284. package/src/lib/serialize-props.ts +7 -0
  285. package/src/lib/unknown-components.ts +64 -0
  286. package/src/lib/virtual-module-generators.ts +58 -0
  287. package/{dist/withHydration-DkKpkmzJ.d.mts → src/lib/withHydration.ts} +25 -8
  288. package/src/loader.ts +145 -0
  289. package/{dist/locales-helpers-BvYYqnJ5.d.mts → src/locales-helpers.ts} +21 -17
  290. package/src/mime-types.ts +19 -0
  291. package/src/page-feed.ts +26 -0
  292. package/src/page-schemas.ts +19 -0
  293. package/src/path-validation.ts +13 -0
  294. package/src/plugin-spa.ts +1496 -0
  295. package/src/puck-manifest/components-endpoint.ts +55 -0
  296. package/src/puck-manifest/field-projection.ts +510 -0
  297. package/src/puck-manifest/index.ts +3 -0
  298. package/src/puck-manifest/literal.ts +459 -0
  299. package/src/puck-manifest/read-config.ts +577 -0
  300. package/src/puck-manifest/read-field.ts +19 -0
  301. package/src/puck-manifest/read-wrapper.ts +1056 -0
  302. package/src/puck-manifest/reading-budget.ts +127 -0
  303. package/src/puck-manifest/resolve-reference.ts +9 -0
  304. package/src/puck-manifest/source-reference.ts +484 -0
  305. package/src/puck-manifest/syntax.ts +104 -0
  306. package/src/puck-manifest/types.ts +139 -0
  307. package/src/safe-json-stringify.ts +17 -0
  308. package/src/sandbox-frame-handler.ts +31 -0
  309. package/src/site-styles/content-wrapper-endpoint.ts +327 -0
  310. package/src/site-styles/render-endpoint.ts +331 -0
  311. package/src/site-styles/styles-endpoint.ts +184 -0
  312. package/src/sitemap-options.ts +115 -0
  313. package/src/tiptap-html-static.ts +134 -0
  314. package/{dist/types-CS9neadI.d.mts → src/types.ts} +87 -124
  315. package/src/virtual-modules.d.ts +74 -0
  316. package/dist/collections-Bd7EME4b.mjs +0 -129
  317. package/dist/collections-Bd7EME4b.mjs.map +0 -1
  318. package/dist/collections.d.mts +0 -35
  319. package/dist/collections.d.mts.map +0 -1
  320. package/dist/collections.mjs +0 -2
  321. package/dist/components.d.mts +0 -41
  322. package/dist/components.d.mts.map +0 -1
  323. package/dist/components.mjs +0 -223
  324. package/dist/components.mjs.map +0 -1
  325. package/dist/hydration.d.mts +0 -4
  326. package/dist/hydration.mjs +0 -2
  327. package/dist/index.d.mts +0 -108
  328. package/dist/index.d.mts.map +0 -1
  329. package/dist/index.mjs +0 -67
  330. package/dist/index.mjs.map +0 -1
  331. package/dist/internal/cms-handler.d.mts +0 -25
  332. package/dist/internal/cms-handler.d.mts.map +0 -1
  333. package/dist/internal/cms-handler.mjs +0 -314
  334. package/dist/internal/cms-handler.mjs.map +0 -1
  335. package/dist/lib/hydration-script.d.mts +0 -30
  336. package/dist/lib/hydration-script.d.mts.map +0 -1
  337. package/dist/lib/hydration-script.mjs +0 -84
  338. package/dist/lib/hydration-script.mjs.map +0 -1
  339. package/dist/locales-helpers-BvYYqnJ5.d.mts.map +0 -1
  340. package/dist/locales-helpers-qiwh7nxS.mjs +0 -54
  341. package/dist/locales-helpers-qiwh7nxS.mjs.map +0 -1
  342. package/dist/node/content.d.mts +0 -18
  343. package/dist/node/content.d.mts.map +0 -1
  344. package/dist/node/content.d.ts +0 -3
  345. package/dist/node/content.d.ts.map +0 -1
  346. package/dist/node/content.js +0 -2
  347. package/dist/node/content.mjs +0 -2
  348. package/dist/node/index.d.mts +0 -200
  349. package/dist/node/index.d.mts.map +0 -1
  350. package/dist/node/index.d.ts +0 -4
  351. package/dist/node/index.d.ts.map +0 -1
  352. package/dist/node/index.js +0 -3
  353. package/dist/node/index.mjs +0 -2513
  354. package/dist/node/index.mjs.map +0 -1
  355. package/dist/serialize-props-BHoNpzH6.mjs +0 -72
  356. package/dist/serialize-props-BHoNpzH6.mjs.map +0 -1
  357. package/dist/src/cms-handler.d.ts.map +0 -1
  358. package/dist/src/collections.d.ts +0 -32
  359. package/dist/src/collections.d.ts.map +0 -1
  360. package/dist/src/collections.js +0 -50
  361. package/dist/src/components/HydrationWrapper.d.ts.map +0 -1
  362. package/dist/src/components/RenderWithBlocks.d.ts.map +0 -1
  363. package/dist/src/components/RenderWithBlocks.js +0 -129
  364. package/dist/src/components/RenderWithHydration.d.ts.map +0 -1
  365. package/dist/src/components.d.ts +0 -4
  366. package/dist/src/components.d.ts.map +0 -1
  367. package/dist/src/components.js +0 -3
  368. package/dist/src/discovery/astro-frontmatter.d.ts.map +0 -1
  369. package/dist/src/discovery/extract-props-ts.d.ts.map +0 -1
  370. package/dist/src/discovery/merge-registry.d.ts.map +0 -1
  371. package/dist/src/discovery/registry-endpoint.d.ts +0 -42
  372. package/dist/src/discovery/registry-endpoint.d.ts.map +0 -1
  373. package/dist/src/discovery/registry-endpoint.js +0 -81
  374. package/dist/src/discovery/scan-components.d.ts.map +0 -1
  375. package/dist/src/discovery/scan-mdx.d.ts.map +0 -1
  376. package/dist/src/discovery/scan-overrides.d.ts.map +0 -1
  377. package/dist/src/hydration.d.ts.map +0 -1
  378. package/dist/src/index.d.ts +0 -11
  379. package/dist/src/index.d.ts.map +0 -1
  380. package/dist/src/index.js +0 -25
  381. package/dist/src/lib/hydration-scanner.d.ts.map +0 -1
  382. package/dist/src/lib/hydration-script.d.ts.map +0 -1
  383. package/dist/src/lib/hydration-utils.d.ts.map +0 -1
  384. package/dist/src/lib/page-api.d.ts +0 -77
  385. package/dist/src/lib/page-api.d.ts.map +0 -1
  386. package/dist/src/lib/page-api.js +0 -121
  387. package/dist/src/lib/route-utils.d.ts.map +0 -1
  388. package/dist/src/lib/routing-config.d.ts.map +0 -1
  389. package/dist/src/lib/serialize-props.d.ts.map +0 -1
  390. package/dist/src/lib/virtual-module-generators.d.ts.map +0 -1
  391. package/dist/src/lib/virtual-module-generators.js +0 -263
  392. package/dist/src/lib/withHydration.d.ts.map +0 -1
  393. package/dist/src/loader.d.ts +0 -14
  394. package/dist/src/loader.d.ts.map +0 -1
  395. package/dist/src/locales-helpers.d.ts.map +0 -1
  396. package/dist/src/mime-types.d.ts.map +0 -1
  397. package/dist/src/path-validation.d.ts.map +0 -1
  398. package/dist/src/plugin-spa.d.ts.map +0 -1
  399. package/dist/src/safe-json-stringify.d.ts.map +0 -1
  400. package/dist/src/site-styles/content-wrapper-endpoint.d.ts.map +0 -1
  401. package/dist/src/site-styles/render-endpoint.d.ts.map +0 -1
  402. package/dist/src/site-styles/styles-endpoint.d.ts.map +0 -1
  403. package/dist/src/types.d.ts.map +0 -1
  404. package/dist/src/types.js +0 -1
  405. package/dist/types-CS9neadI.d.mts.map +0 -1
  406. package/dist/withHydration-C256ox_6.mjs +0 -49
  407. package/dist/withHydration-C256ox_6.mjs.map +0 -1
  408. package/dist/withHydration-DkKpkmzJ.d.mts.map +0 -1
  409. /package/dist/{src → ts/src}/discovery/astro-frontmatter.d.ts +0 -0
  410. /package/dist/{src → ts/src}/discovery/extract-props-ts.d.ts +0 -0
  411. /package/dist/{src → ts/src}/discovery/scan-mdx.d.ts +0 -0
  412. /package/dist/{src → ts/src}/discovery/scan-overrides.d.ts +0 -0
  413. /package/dist/{src → ts/src}/hydration.d.ts +0 -0
  414. /package/dist/{src → ts/src}/lib/hydration-scanner.d.ts +0 -0
  415. /package/dist/{src → ts/src}/lib/hydration-script.d.ts +0 -0
  416. /package/dist/{src → ts/src}/lib/hydration-utils.d.ts +0 -0
  417. /package/dist/{src → ts/src}/lib/serialize-props.d.ts +0 -0
  418. /package/dist/{src → ts/src}/lib/withHydration.d.ts +0 -0
  419. /package/dist/{src → ts/src}/locales-helpers.d.ts +0 -0
  420. /package/dist/{src → ts/src}/mime-types.d.ts +0 -0
  421. /package/dist/{src → ts/src}/path-validation.d.ts +0 -0
  422. /package/dist/{src → ts/src}/safe-json-stringify.d.ts +0 -0
package/README.md CHANGED
@@ -5,361 +5,314 @@ managing content using Puck's drag-and-drop editor, allowing developers to creat
5
5
  maintaining full control over their content structure. The CMS integrates seamlessly into your Astro development
6
6
  workflow, accessible at `/__cms` routes without requiring authentication or complex setup.
7
7
 
8
- ## MDX component registry
9
-
10
- Hosts can register JSX components (their own, or third-party ones like Starlight's `<Steps>`, `<Tabs>`, `<Card>`) with
11
- the MDX editor so authors get typed insert affordances and optional auto-import injection. The registry is wired through
12
- the same `schemasPath` option that already loads `pageSchemas` — add an `mdxComponents` export to the file and the CMS
13
- picks it up at boot (and on HMR).
14
-
15
- ```ts
16
- // src/schemas.ts
17
- import { defineMdxComponents } from '@conloca/astro-cms';
8
+ ## Getting started
18
9
 
19
- export const pageSchemas = {
20
- /* existing entries */
21
- };
10
+ ### Install
22
11
 
23
- export const mdxComponents = defineMdxComponents([
24
- {
25
- name: 'Steps',
26
- kind: 'flow',
27
- hasChildren: true,
28
- insert: { label: 'Steps', description: 'Numbered step-by-step list', icon: 'list-ordered' },
29
- defaults: { children: '1. First step\n2. Second step\n3. Third step' },
30
- import: { from: '@astrojs/starlight/components' },
31
- },
32
- // …other components your site uses
33
- ]);
12
+ ```bash
13
+ npm install @conloca/astro-cms
14
+ npm install @astrojs/react @vitejs/plugin-react astro react react-dom vite zod
34
15
  ```
35
16
 
36
- Starlight components are declared the same way as any other component — the CMS does not ship Starlight descriptors.
37
- Copy the props you need from each component's source (e.g.
38
- `node_modules/@astrojs/starlight/user-components/<Component>.astro`).
39
-
40
- In the editor, registered components appear in two places:
41
-
42
- - A slash menu, opened by typing `/` in the body. Filter by name, label, description, or keywords.
43
- - A toolbar dropdown next to the admonition button, listing block-level (`kind: 'flow'`) components.
17
+ The second line is the full peer set — the CMS expects the host site to own those packages. `@astrojs/react` is not
18
+ optional: the editor is a React application, and this integration does not register Astro's React renderer for you. A
19
+ site that omits it serves the editor route with no editor in it.
44
20
 
45
- ### Auto-import injection (and its pruning caveat)
21
+ ### The four files a site needs
46
22
 
47
- Setting `import: { from: '<module>' }` on a descriptor opts the component into automatic import injection: whenever the
48
- component appears in the document, the CMS save serializer emits the matching `import { Name } from '<module>'` line at
49
- the top of the file (after frontmatter).
23
+ A working site needs all four of these. Omitting any one of them breaks the site or the editor, in most cases without an
24
+ error message.
50
25
 
51
- **Important: the editor rebuilds the import block on every save from components actually referenced in the tree.**
52
- Imports for unused components are dropped. So are non-JSX imports — type imports, side-effect imports
53
- (`import './styles.css'`), and helper-function imports — because the editor does not consider them "referred to" by a
54
- JSX node. This is a hard constraint of the underlying `@mdxeditor/editor` export pipeline
55
- ([`exportMarkdownFromLexical.js:98-148`](../../node_modules/@mdxeditor/editor/dist/exportMarkdownFromLexical.js)), not a
56
- policy choice.
26
+ #### 1. `astro.config.mjs`
57
27
 
58
- For Starlight-flavored docs (where MDX only imports Starlight components from `@astrojs/starlight/components`) the
59
- behavior matches authorial intent — imports follow usage. For richer MDX that relies on type or side-effect imports,
60
- edit those files in your IDE rather than the CMS, or omit `import.from` from your descriptors so the editor does not
61
- claim ownership of the import line.
28
+ `react()` must be listed before `conlocaCMS()`.
62
29
 
63
- ## How Astro Integrations Are Built
30
+ ```js
31
+ import react from '@astrojs/react';
32
+ import { conlocaCMS } from '@conloca/astro-cms/node';
33
+ import { defineConfig } from 'astro/config';
64
34
 
65
- Based on research of official Astro integrations:
66
-
67
- ### Build Tools Used
68
-
69
- 1. **astro-scripts** - Official Astro integrations use `astro-scripts` for building:
70
-
71
- ```json
72
- {
73
- "scripts": {
74
- "build": "astro-scripts build \"src/**/*.ts\" && tsc",
75
- "build:ci": "astro-scripts build \"src/**/*.ts\""
76
- }
77
- }
78
- ```
79
-
80
- 2. **TypeScript Compilation** - Standard `tsc` for type definitions:
81
- - Compiles `.ts` files to `.js`
82
- - Generates `.d.ts` type definitions
83
- - Does NOT compile `.astro` files
84
-
85
- 3. **Package Exports** - Modern ESM exports in package.json:
86
- ```json
87
- {
88
- "exports": {
89
- ".": "./dist/index.js",
90
- "./package.json": "./package.json"
91
- }
92
- }
93
- ```
94
-
95
- ### How Integrations Ship UI
35
+ export default defineConfig({
36
+ integrations: [
37
+ react(),
38
+ conlocaCMS({
39
+ contentRoot: './content',
40
+ puckConfigPath: './src/puck.config.tsx',
41
+ layout: './src/layouts/Layout.astro',
42
+ }),
43
+ ],
44
+ });
45
+ ```
96
46
 
97
- Official integrations handle UI in several ways:
47
+ Import the integration from `@conloca/astro-cms/node`, not from the package root. The root export deliberately throws
48
+ with a message pointing at the `/node` subpath: the root entry stays free of Node-only code so it can load in any
49
+ runtime, including the browser.
98
50
 
99
- 1. **API Endpoints Only** (Most common)
100
- - Example: `@astrojs/web-vitals` injects API routes
101
- - No UI components shipped
51
+ `puckConfigPath` points at a module whose default export is a Puck `Config` — the components it lists become the
52
+ editor's palette, and the folders they live in are what the integration scans for hydratable components.
102
53
 
103
- 2. **Client-Side Scripts** (Common)
104
- - Example: Dev toolbar integrations
105
- - Ship JavaScript that runs on the client
106
- - Injected via `injectScript()`
54
+ ```tsx
55
+ // src/puck.config.tsx
56
+ import type { Config } from '@puckeditor/core';
57
+ import { Text } from './components/puck/Text';
107
58
 
108
- 3. **Middleware Approach** (Common)
109
- - Example: `@astrojs/node` adds Express middleware
110
- - Serves content programmatically
59
+ const puckConfig: Config = {
60
+ components: {
61
+ Text,
62
+ },
63
+ };
111
64
 
112
- 4. **Virtual Modules** (Advanced)
113
- - Example: `@astrojs/db` uses virtual modules
114
- - Routes are generated at build time
115
- - Uses Vite's virtual module system
65
+ export default puckConfig;
66
+ ```
116
67
 
117
- ### Building Non-Standard Integrations
68
+ These must be React components. An `.astro` component cannot be listed here — Astro compiles those into a server-side
69
+ renderer with its own hydration model, so they cannot be wrapped as React components for the editor to render.
118
70
 
119
- For integrations that need to ship actual UI:
71
+ #### 2. `src/content.config.ts`
120
72
 
121
- 1. **Custom Build Process**
122
- - Can use any build tool (Vite, Rollup, esbuild)
123
- - Not limited to `tsc` only
124
- - Example: Bundle React app and serve via middleware
73
+ **Without this file every content page returns 404.** The integration registers the routes, but Astro only has content
74
+ to render once the collections are defined, and defining them is this file's whole job.
125
75
 
126
- 2. **Asset Handling**
127
- - Static assets can be included in the package
128
- - Served via middleware or virtual modules
129
- - Example: CSS files, images, bundled JavaScript
76
+ ```ts
77
+ import { conlocaData, conlocaFragments, conlocaPages } from '@conloca/astro-cms/node/content';
78
+ import { dataSchemas, pageSchemas } from './schemas';
130
79
 
131
- 3. **Route Injection Patterns**
80
+ export const collections = {
81
+ pages: conlocaPages({ pageSchemas }),
82
+ ...conlocaData({ dataSchemas }),
83
+ ...conlocaFragments('general'),
84
+ };
85
+ ```
132
86
 
133
- ```typescript
134
- // Inject API routes (standard)
135
- injectRoute({
136
- pattern: '/api/[...path]',
137
- entrypoint: '@my-pkg/api-handler',
138
- });
87
+ The keys are the collection names, and `dataSchemas`' own keys become the data collections — nothing is named twice. A
88
+ site with no custom page fields writes `conlocaPages()` on its own, and a site with no data collections drops the
89
+ `conlocaData` line; `conlocaFragments()` with no names still defines the aggregate the renderer reads. No paths are
90
+ passed: the integration publishes its `contentRoot` option through the environment before the content config loads, so
91
+ the one path in `astro.config.mjs` covers both.
92
+
93
+ Entries come back typed — `getCollection('pages')` carries `pathname`, `title`, the dates and, via the `HostPageMeta`
94
+ augmentation, the host's own page fields, and a data entry carries `data` typed by its schema. That `data` is optional
95
+ (`data?: T`): an entry saved before any payload exists is not an error, so readers guard the access. Content the config
96
+ does not declare fails the build, and the error names the collection and its kind, rather than silently not building;
97
+ declaring a collection before its folder exists is the normal order, since the folder appears with the first entry saved
98
+ in the editor. The editor saves new fragments in the `fragments` folder, and every form of `conlocaFragments(...)`
99
+ declares that folder, so it never needs naming for the build to accept it.
100
+
101
+ A site with no MDX fragments yet prints this once per rendered page, and it is expected — nothing is wrong with the file
102
+ this message points at:
103
+
104
+ ```plain
105
+ The collection "__conloca_fragments" does not exist or is empty. Please check your content config file for errors.
106
+ ```
139
107
 
140
- // Inject catch-all for SPA (for client routing)
141
- injectRoute({
142
- pattern: '/__cms/[...path]',
143
- entrypoint: '@my-pkg/spa-handler',
144
- });
145
- ```
108
+ Astro prints it from `getCollection()` whenever a collection holds no entries, and there is no way to register an empty
109
+ one — leaving the collection out produces the very same message. It stops as soon as the site has one published
110
+ fragment.
146
111
 
147
- ### Shipping .astro Files (Possible but Rare)
112
+ #### 3. `content/sites.json`
148
113
 
149
- While uncommon, packages CAN ship .astro files:
114
+ Lives at the root of `contentRoot` and declares the sites and their locales. A single-site setup names its site
115
+ `default`, which is the site name every other default assumes.
150
116
 
151
117
  ```json
152
118
  {
153
- "exports": {
154
- "./pages/index.astro": "./src/pages/index.astro"
155
- }
119
+ "sites": {
120
+ "default": {
121
+ "locales": ["en"],
122
+ "defaultLocale": "en"
123
+ }
124
+ },
125
+ "globalLocales": ["en"]
156
126
  }
157
127
  ```
158
128
 
159
- However, this requires:
160
-
161
- - Including source .astro files in npm package
162
- - Proper export configuration
163
- - User's Astro instance compiles them at build time
129
+ If the file is missing the CMS logs a warning and falls back to an empty site list, which means no page collections get
130
+ created — the same symptom as a missing content config.
164
131
 
165
- ### For This CMS
132
+ #### 4. The layout named by `layout`
166
133
 
167
- Given the requirements:
134
+ An ordinary Astro layout. It receives `title` and `description`, and renders the page body through `<slot />`. It also
135
+ receives `page`, the page being rendered with its settings in `page.meta`; read extra head fields such as an Open Graph
136
+ image from there rather than querying the collection again.
168
137
 
169
- - React-based UI (Puck editor)
170
- - Client-side routing needed
171
- - Development-only usage
138
+ ```astro
139
+ ---
140
+ interface Props {
141
+ title?: string;
142
+ description?: string;
143
+ }
172
144
 
173
- The optimal approach is:
145
+ const { title, description } = Astro.props;
146
+ ---
147
+
148
+ <!doctype html>
149
+ <html lang="en">
150
+ <head>
151
+ <meta charset="utf-8" />
152
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
153
+ <title>{title ?? 'My site'}</title>
154
+ {description && <meta name="description" content={description} />}
155
+ </head>
156
+ <body>
157
+ <slot />
158
+ </body>
159
+ </html>
160
+ ```
174
161
 
175
- 1. Build the CMS as a Vite-based React SPA
176
- 2. Bundle it during package build
177
- 3. Serve via middleware with catch-all routing
178
- 4. Use Astro's API routes for data endpoints
162
+ Supplying `layout` and nothing else turns on a catch-all `/[...slug]` route over the `pages` collection with a `404`
163
+ fallback. Sites that need more than one route drop `layout` and use `routing.routes.<name>.layout` instead.
164
+
165
+ With those four files in place, run the Astro dev server and open `/__cms`.
166
+
167
+ ### Options
168
+
169
+ Passed to `conlocaCMS({ ... })`. Only two are required.
170
+
171
+ | Option | Required | What it does |
172
+ | ---------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
173
+ | `contentRoot` | yes | Directory holding `sites.json` and the content files. Also handed to the collection factories, so the content config needs no copy of it. |
174
+ | `puckConfigPath` | yes | Module whose default export is the Puck `Config`. Supplies the visual editor's component palette and seeds component auto-discovery. |
175
+ | `canvasDir` | no | Directory for canvas documents. |
176
+ | `route` | no | Where the CMS mounts. Defaults to `/__cms`. |
177
+ | `layout` | no | Default layout for content pages. On its own it enables routing with a catch-all pattern. |
178
+ | `routing` | no | Full routing configuration, for sites with more than one content route. |
179
+ | `templates` | no | Page templates offered in the create-page dialog. |
180
+ | `schemasPath` | no | Module exporting `dataSchemas`, `pageSchemas` and `mdxComponents`. Drives the page-settings form and the MDX component registry. |
181
+ | `componentPaths` | no | Extra folders to scan for components wrapped in `withHydration()`. |
182
+ | `mdxComponentFolders` | no | Folders scanned for locally authored MDX components, whose `interface Props` becomes the editor's prop panel. Defaults to `['src/components/mdx']`. |
183
+ | `assetsPath` | no | Upload directory; enables the Media Library. The site must serve it from `publicDir`, directly or through a link there, or dev and build fail. |
184
+ | `siteStyles` | no | CSS injected into the Puck preview iframe so components render with site styling. |
185
+ | `editorStyles` | no | CSS injected into the MDX editor's admin document. Host-component selectors only — see the file's own notes on what does not belong. |
186
+ | `editorCSS` | no | Raw CSS applied after auto-discovered host styles in the editor's host-preview layer. |
187
+ | `fragmentPreviewRoute` | no | Route whose styles and content wrapper frame the standalone fragment editor. Defaults to `/`. |
188
+ | `locales` | no | The site's locales and default locale. Without it: the site's `locales` and `defaultLocale` in `sites.json`, else `globalLocales`. |
189
+
190
+ `ConlocaCMSOptions` also extends the editor's `UIConfig` (minus `basename`), so fields such as `apiBaseUrl`,
191
+ `siteBaseUrl`, `enableDevtools`, `queryClientOptions`, `projectRoot` and `hosted` are accepted as well. Those exist for
192
+ hosts that embed the editor in their own shell; an ordinary Astro site leaves them alone.
193
+
194
+ **`puckConfigPath` and `schemasPath` are unrelated options.** They resolve different files, feed different parts of the
195
+ CMS, and neither falls back to the other. `puckConfigPath` is required and supplies the visual page editor's component
196
+ palette. `schemasPath` is optional and supplies frontmatter forms plus the MDX component registry described below.
197
+ Setting `schemasPath` does not make `puckConfigPath` unnecessary, and a site with no `schemasPath` still works — it just
198
+ has no custom page-settings fields and no registered MDX components.
199
+
200
+ ### Sitemap for on-demand pages
201
+
202
+ A static build writes a file for every published page, and `@astrojs/sitemap` lists those by itself. A route with
203
+ `prerender: false` renders its pages on demand instead, so there is no file to find and the sitemap leaves them out.
204
+ `conlocaSitemapOptions` returns the two `@astrojs/sitemap` options the CMS's pages need: `customPages`, the full address
205
+ of every published page the CMS routes serve, and `serialize`, which gives each of them its last-edit date as
206
+ `<lastmod>`. Addresses follow your `site`, `base`, `trailingSlash` and `build.format`, so hand it the same settings you
207
+ give Astro, along with the same options as `conlocaCMS()`:
208
+
209
+ ```js
210
+ import node from '@astrojs/node';
211
+ import react from '@astrojs/react';
212
+ import sitemap from '@astrojs/sitemap';
213
+ import { conlocaCMS, conlocaSitemapOptions } from '@conloca/astro-cms/node';
214
+ import { defineConfig } from 'astro/config';
215
+
216
+ // Every setting that decides a page's address, shared by Astro and the sitemap.
217
+ const urls = { site: 'https://example.com', trailingSlash: 'always' };
218
+ const cmsOptions = {
219
+ contentRoot: './content',
220
+ puckConfigPath: './src/puck.config.tsx',
221
+ routing: {
222
+ routes: {
223
+ pages: { pattern: '/[...slug]', layout: './src/layouts/Layout.astro', prerender: false },
224
+ },
225
+ },
226
+ };
179
227
 
180
- This aligns with how tools like Vite's dev UI and other development tools integrate with build systems.
228
+ export default defineConfig({
229
+ ...urls,
230
+ adapter: node({ mode: 'standalone' }),
231
+ integrations: [react(), sitemap(await conlocaSitemapOptions(cmsOptions, urls)), conlocaCMS(cmsOptions)],
232
+ });
233
+ ```
181
234
 
182
- ## Research: Using .astro Components in React/Puck
235
+ The list is read when the config loads, so publish and unpublish dates count as of the build. If a CMS route is
236
+ prerendered after all, its pages get the address Astro gives them, so each appears once, not twice. Pages are listed in
237
+ the language the CMS routes serve (`routing.locale`), because the routes give other languages no address. A page whose
238
+ last-edit date cannot be read is listed without `<lastmod>` instead of failing the build. To pass sitemap options of
239
+ your own as well, put them in one object with these, as in
240
+ `sitemap({ ...(await conlocaSitemapOptions(cmsOptions, urls)), changefreq: 'weekly' })`. A `serialize` of your own
241
+ replaces this one, so call this one inside it.
183
242
 
184
- Based on investigation of Astro's source code, here's what was discovered about rendering .astro components within
185
- React:
243
+ ### Listing CMS pages on an Astro page
186
244
 
187
- ### How .astro Components Work
245
+ A block on a CMS page gets its list of pages from the route's `dataBindings.pages`. An ordinary Astro page, such as a
246
+ blog index or an RSS route, asks for the same list through `@conloca/astro-cms/page-feed`:
188
247
 
189
- 1. **Compilation Process**
190
- ([astro/packages/astro/src/vite-plugin-astro/compile.ts](https://github.com/withastro/astro/blob/main/packages/astro/src/vite-plugin-astro/compile.ts)):
191
- - .astro files are transformed by `@astrojs/compiler` into TypeScript/JavaScript
192
- - The output is an `AstroComponentFactory` function, not a React component
193
- - Components include metadata for hydration, slots, and server-side rendering
248
+ ```astro
249
+ ---
250
+ import { getPagesByPrefix } from '@conloca/astro-cms/page-feed';
194
251
 
195
- 2. **Component Factory Structure**
196
- ([astro/packages/astro/src/runtime/server/render/astro/factory.ts](https://github.com/withastro/astro/blob/main/packages/astro/src/runtime/server/render/astro/factory.ts)):
252
+ const posts = await getPagesByPrefix('/blog/');
253
+ ---
197
254
 
198
- ```typescript
199
- interface AstroComponentFactory {
200
- (result: any, props: any, slots: any): AstroFactoryReturnValue;
201
- isAstroComponentFactory?: boolean;
202
- moduleId?: string;
203
- propagation?: PropagationHint;
204
- }
205
- ```
255
+ <ul>
256
+ {posts.map((post) => <li><a href={post.pathname}>{post.title}</a></li>)}
257
+ </ul>
258
+ ```
206
259
 
207
- 3. **Container API**
208
- ([astro/packages/astro/src/container/index.ts](https://github.com/withastro/astro/blob/main/packages/astro/src/container/index.ts)):
209
- - Provides `experimental_AstroContainer` for programmatic rendering
210
- - Can render .astro components to HTML strings via `renderToString()`
211
- - Server-side only - returns static HTML, not React components
260
+ The list holds the published pages under the prefix, in the site's language, without the page at the prefix itself. Each
261
+ entry is a `PageReference`: `meta` carries the page's own fields, including the ones `pageSchemas` declares, and
262
+ `timestamps` carries created, modified and published dates. `published` is the page's publish time or, when it has none,
263
+ its creation time. The second argument takes `sort` (`'date-desc'`, the default, puts the newest publish date first, so
264
+ editing a page never moves it; `'date-asc'` and `'title'` are the others; pages that tie are listed by path), `limit`,
265
+ and `locale` to read another language. It reads the pages of the content routes `conlocaCMS()` serves, so it needs
266
+ `layout` or `routing` set there and throws when neither is.
212
267
 
213
- ### Rendering .astro Components
268
+ ## MDX component registry
214
269
 
215
- The Container API allows server-side rendering of .astro components:
270
+ Hosts can register JSX components (their own, or third-party ones like Starlight's `<Steps>`, `<Tabs>`, `<Card>`) with
271
+ the MDX editor so authors get typed insert affordances and optional auto-import injection. The registry is wired through
272
+ the same `schemasPath` option that already loads `pageSchemas` — add an `mdxComponents` export to the file and the CMS
273
+ picks it up at boot (and on HMR).
216
274
 
217
- ```typescript
218
- // Example from astro/examples/container-with-vitest/test/ReactWrapper.test.ts
219
- import { experimental_AstroContainer as AstroContainer } from 'astro/container';
220
- import { getContainerRenderer } from '@astrojs/react';
221
- import Component from '../src/components/Component.astro';
275
+ ```ts
276
+ // src/schemas.ts
277
+ import { defineMdxComponents } from '@conloca/astro-cms';
222
278
 
223
- const container = await AstroContainer.create({
224
- renderers: [getContainerRenderer()],
225
- });
279
+ export const pageSchemas = {/* existing entries */};
226
280
 
227
- const html = await container.renderToString(Component, {
228
- props: {
229
- /* component props */
281
+ export const mdxComponents = defineMdxComponents([
282
+ {
283
+ name: 'Steps',
284
+ kind: 'flow',
285
+ hasChildren: true,
286
+ insert: { label: 'Steps', description: 'Numbered step-by-step list', icon: 'list-ordered' },
287
+ defaults: { children: '1. First step\n2. Second step\n3. Third step' },
288
+ import: { from: '@astrojs/starlight/components' },
230
289
  },
231
- slots: { default: 'Slot content' },
232
- });
290
+ // …other components your site uses
291
+ ]);
233
292
  ```
234
293
 
235
- ### Integration Approaches
236
-
237
- #### 1. Server-Side HTML Rendering (Limited)
238
-
239
- - Render .astro components to HTML strings server-side
240
- - Display in React using `dangerouslySetInnerHTML`
241
- - No client-side interactivity preserved
242
- - Requires API endpoint to render components on demand
294
+ Starlight components are declared the same way as any other component — the CMS does not ship Starlight descriptors.
295
+ Copy the props you need from each component's source (e.g.
296
+ `node_modules/@astrojs/starlight/user-components/<Component>.astro`).
243
297
 
244
- #### 2. Astro Islands Architecture ([astro/packages/astro/src/runtime/server/astro-island.ts](https://github.com/withastro/astro/blob/main/packages/astro/src/runtime/server/astro-island.ts))
298
+ In the editor, registered components appear in two places:
245
299
 
246
- - Astro uses custom `<astro-island>` elements for hydration
247
- - Complex hydration system with directives (`client:load`, `client:idle`, etc.)
248
- - Not designed for embedding within React components
249
- - Would require significant work to integrate with React's lifecycle
300
+ - A slash menu, opened by typing `/` in the body. Filter by name, label, description, or keywords.
301
+ - A toolbar dropdown next to the admonition button, listing block-level (`kind: 'flow'`) components.
250
302
 
251
- #### 3. Direct Component Usage (Not Possible)
303
+ ### Auto-import injection (and its pruning caveat)
252
304
 
253
- - .astro components cannot be directly imported and used as React components
254
- - Different component models: Astro uses server-first rendering with partial hydration
255
- - React expects components that return React elements
256
-
257
- ### Recommendation
258
-
259
- **Use React components in Puck, not .astro components:**
260
-
261
- 1. Create shared React components that can be used by both:
262
- - Astro pages (via React integration)
263
- - Puck editor (native React)
264
-
265
- 2. Example structure:
266
-
267
- ```
268
- src/
269
- components/
270
- Hero.tsx # React component
271
- Card.tsx # React component
272
- pages/
273
- index.astro # Uses React components
274
- puck.config.ts # Also uses React components
275
- ```
276
-
277
- 3. Benefits:
278
- - Full interactivity in the CMS
279
- - Consistent behavior between CMS preview and production
280
- - No complex wrapping or conversion needed
281
- - Proper TypeScript support and props validation
282
-
283
- ### Technical Constraints
284
-
285
- Based on the source code analysis:
286
-
287
- 1. **No React Wrapper Exists**: Astro doesn't provide a way to wrap .astro components for use in React
288
- 2. **Different Rendering Models**: Astro's server-first, partial hydration model is incompatible with React's
289
- client-side model
290
- 3. **Container API Limitations**: Only provides server-side rendering to HTML strings, not interactive components
291
-
292
- ### Conclusion
293
-
294
- While .astro components excel at server-side rendering with selective hydration, they cannot be meaningfully wrapped as
295
- React components for use in Puck. The recommended approach is to use React components throughout the Puck configuration,
296
- which can also be used in Astro pages via the React integration.
297
-
298
- ## Astro Development Mode and HMR
299
-
300
- ### How Astro Handles Hot Module Replacement
301
-
302
- Based on analysis of the Astro source code:
303
-
304
- 1. **Compilation Pipeline**
305
- ([astro/packages/astro/src/vite-plugin-astro/index.ts](https://github.com/withastro/astro/blob/main/packages/astro/src/vite-plugin-astro/index.ts)):
306
- - `@astrojs/compiler` transforms .astro files into JavaScript
307
- - `vite-plugin-astro` orchestrates this compilation
308
- - The plugin integrates with Vite's module system
309
-
310
- 2. **HMR Implementation**
311
- ([astro/packages/astro/src/vite-plugin-astro/hmr.ts](https://github.com/withastro/astro/blob/main/packages/astro/src/vite-plugin-astro/hmr.ts)):
312
- - Vite watches for file changes and triggers `handleHotUpdate`
313
- - Astro optimizes HMR for specific change types:
314
- - Style-only changes: Only CSS virtual modules are invalidated
315
- - CSS dependencies: Invalidates compile metadata when CSS imports change
316
- - Full changes: Re-compiles the entire component
317
- - Vite's HMR system propagates updates to the browser
318
-
319
- 3. **Development Flow**:
320
- ```
321
- .astro file changes → Vite detects → vite-plugin-astro compiles →
322
- @astrojs/compiler transforms → JavaScript output → Vite HMR update → Browser
323
- ```
324
-
325
- ### Implications for Puck Config Loading
326
-
327
- Since Vite handles all module loading and HMR in Astro's dev mode:
328
-
329
- 1. **Virtual Modules**: We can use Vite's virtual module system to serve the Puck config
330
- 2. **Automatic HMR**: Changes to puck.config.ts will trigger HMR automatically
331
- 3. **Component Bundling**: Vite will handle bundling React components in the config
332
- 4. **No Custom Build**: We don't need a separate build process for the config
333
-
334
- Example virtual module approach:
335
-
336
- ```typescript
337
- // In the Astro plugin
338
- vite: {
339
- plugins: [
340
- {
341
- name: 'conloca-cms-config',
342
- resolveId(id) {
343
- if (id === 'virtual:conloca-cms/puck-config') {
344
- return '\0virtual:conloca-cms/puck-config';
345
- }
346
- },
347
- load(id) {
348
- if (id === '\0virtual:conloca-cms/puck-config') {
349
- return `
350
- import { puckConfig } from '${userPuckConfigPath}';
351
- export default puckConfig;
352
- `;
353
- }
354
- },
355
- },
356
- ];
357
- }
358
- ```
305
+ Setting `import: { from: '<module>' }` on a descriptor opts the component into automatic import injection: whenever the
306
+ component appears in the document, the CMS save serializer emits the matching `import { Name } from '<module>'` line at
307
+ the top of the file (after frontmatter).
359
308
 
360
- Benefits:
309
+ **Important: the editor rebuilds the import block on every save from components actually referenced in the tree.**
310
+ Imports for unused components are dropped. So are non-JSX imports — type imports, side-effect imports
311
+ (`import './styles.css'`), and helper-function imports — because the editor does not consider them "referred to" by a
312
+ JSX node. This is a hard constraint of the underlying `@mdxeditor/editor` export pipeline (see
313
+ `dist/exportMarkdownFromLexical.js` in that package), not a policy choice.
361
314
 
362
- - Leverages existing Vite infrastructure
363
- - HMR works out of the box
364
- - No additional complexity for module loading
365
- - React components are properly bundled
315
+ For Starlight-flavored docs (where MDX only imports Starlight components from `@astrojs/starlight/components`) the
316
+ behavior matches authorial intent — imports follow usage. For richer MDX that relies on type or side-effect imports,
317
+ edit those files in your IDE rather than the CMS, or omit `import.from` from your descriptors so the editor does not
318
+ claim ownership of the import line.
@@ -1,7 +1,15 @@
1
- import { createRequire } from 'node:module';
1
+ // Uniform acorn surface for SSR builds: some toolchain consumers
2
+ // default-import acorn (which its ESM build does not provide), others use
3
+ // named imports — this shim serves both. Resolved with a static import, never
4
+ // a Node require built from `import.meta.url` — that value is undefined
5
+ // inside a Workers bundle, and building one at module scope throws before the
6
+ // bundle can serve anything. The
7
+ // integration's alias plugin skips this file as an importer, so the specifier
8
+ // below reaches the real package instead of recursing into the shim.
9
+ import * as acornModule from 'acorn';
2
10
 
3
- const require = createRequire(import.meta.url);
4
- const acorn = require('acorn');
11
+ // Bundler CJS interop can surface the namespace under `default`.
12
+ const acorn = acornModule.Parser ? acornModule : acornModule.default;
5
13
 
6
14
  export const Node = acorn.Node;
7
15
  export const Parser = acorn.Parser;