@conloca/astro-cms 0.1.15 → 0.2.0

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