@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.
- package/README.md +259 -247
- package/dist/internal/acorn-default.mjs +11 -3
- package/dist/internal/page-handler.astro +137 -358
- package/dist/ts/node/content.d.ts +4 -0
- package/dist/ts/node/content.d.ts.map +1 -0
- package/dist/ts/node/content.js +3 -0
- package/dist/ts/node/content.js.map +1 -0
- package/dist/ts/node/index.d.ts +9 -0
- package/dist/ts/node/index.d.ts.map +1 -0
- package/dist/ts/node/index.js +14 -0
- package/dist/ts/node/index.js.map +1 -0
- package/dist/ts/src/asset-ref-base.d.ts +3 -0
- package/dist/ts/src/asset-ref-base.d.ts.map +1 -0
- package/dist/ts/src/asset-ref-base.js +48 -0
- package/dist/ts/src/asset-ref-base.js.map +1 -0
- package/dist/ts/src/checks.d.ts +7 -0
- package/dist/ts/src/checks.d.ts.map +1 -0
- package/dist/ts/src/checks.js +7 -0
- package/dist/ts/src/checks.js.map +1 -0
- package/dist/ts/src/cms-handler.d.ts +18 -0
- package/dist/ts/src/cms-handler.d.ts.map +1 -0
- package/dist/ts/src/cms-handler.js +245 -0
- package/dist/ts/src/cms-handler.js.map +1 -0
- package/dist/ts/src/collections.d.ts +160 -0
- package/dist/ts/src/collections.d.ts.map +1 -0
- package/dist/ts/src/collections.js +170 -0
- package/dist/ts/src/collections.js.map +1 -0
- package/dist/ts/src/components/HydrationWrapper.d.ts +18 -0
- package/dist/ts/src/components/HydrationWrapper.d.ts.map +1 -0
- package/dist/ts/src/components/HydrationWrapper.js +22 -0
- package/dist/ts/src/components/HydrationWrapper.js.map +1 -0
- package/dist/ts/src/components/RenderWithFragments.d.ts +27 -0
- package/dist/ts/src/components/RenderWithFragments.d.ts.map +1 -0
- package/dist/ts/src/components/RenderWithFragments.js +133 -0
- package/dist/ts/src/components/RenderWithFragments.js.map +1 -0
- package/dist/ts/src/components/RenderWithHydration.d.ts +21 -0
- package/dist/ts/src/components/RenderWithHydration.d.ts.map +1 -0
- package/dist/ts/src/components/RenderWithHydration.js +39 -0
- package/dist/ts/src/components/RenderWithHydration.js.map +1 -0
- package/dist/ts/src/components.d.ts +4 -0
- package/dist/ts/src/components.d.ts.map +1 -0
- package/dist/ts/src/components.js +4 -0
- package/dist/ts/src/components.js.map +1 -0
- package/dist/ts/src/discovery/astro-frontmatter.d.ts +18 -0
- package/dist/ts/src/discovery/astro-frontmatter.d.ts.map +1 -0
- package/dist/ts/src/discovery/astro-frontmatter.js +25 -0
- package/dist/ts/src/discovery/astro-frontmatter.js.map +1 -0
- package/dist/ts/src/discovery/discover.d.ts +43 -0
- package/dist/ts/src/discovery/discover.d.ts.map +1 -0
- package/dist/ts/src/discovery/discover.js +87 -0
- package/dist/ts/src/discovery/discover.js.map +1 -0
- package/dist/ts/src/discovery/extract-props-ts.d.ts +41 -0
- package/dist/ts/src/discovery/extract-props-ts.d.ts.map +1 -0
- package/dist/ts/src/discovery/extract-props-ts.js +232 -0
- package/dist/ts/src/discovery/extract-props-ts.js.map +1 -0
- package/dist/ts/src/discovery/merge-registry.d.ts +58 -0
- package/dist/ts/src/discovery/merge-registry.d.ts.map +1 -0
- package/dist/ts/src/discovery/merge-registry.js +333 -0
- package/dist/ts/src/discovery/merge-registry.js.map +1 -0
- package/dist/ts/src/discovery/registry-endpoint.d.ts +27 -0
- package/dist/ts/src/discovery/registry-endpoint.d.ts.map +1 -0
- package/dist/ts/src/discovery/registry-endpoint.js +76 -0
- package/dist/ts/src/discovery/registry-endpoint.js.map +1 -0
- package/dist/ts/src/discovery/scan-components.d.ts +94 -0
- package/dist/ts/src/discovery/scan-components.d.ts.map +1 -0
- package/dist/ts/src/discovery/scan-components.js +397 -0
- package/dist/ts/src/discovery/scan-components.js.map +1 -0
- package/dist/ts/src/discovery/scan-mdx.d.ts +63 -0
- package/dist/ts/src/discovery/scan-mdx.d.ts.map +1 -0
- package/dist/ts/src/discovery/scan-mdx.js +113 -0
- package/dist/ts/src/discovery/scan-mdx.js.map +1 -0
- package/dist/ts/src/discovery/scan-overrides.d.ts +71 -0
- package/dist/ts/src/discovery/scan-overrides.d.ts.map +1 -0
- package/dist/ts/src/discovery/scan-overrides.js +34 -0
- package/dist/ts/src/discovery/scan-overrides.js.map +1 -0
- package/dist/ts/src/editor-descriptors.d.ts +31 -0
- package/dist/ts/src/editor-descriptors.d.ts.map +1 -0
- package/dist/ts/src/editor-descriptors.js +84 -0
- package/dist/ts/src/editor-descriptors.js.map +1 -0
- package/dist/ts/src/handlers/collection-content-api.d.ts +32 -0
- package/dist/ts/src/handlers/collection-content-api.d.ts.map +1 -0
- package/dist/ts/src/handlers/collection-content-api.js +166 -0
- package/dist/ts/src/handlers/collection-content-api.js.map +1 -0
- package/dist/ts/src/handlers/page-render-core.d.ts +137 -0
- package/dist/ts/src/handlers/page-render-core.d.ts.map +1 -0
- package/dist/ts/src/handlers/page-render-core.js +315 -0
- package/dist/ts/src/handlers/page-render-core.js.map +1 -0
- package/dist/ts/src/hydration.d.ts +4 -0
- package/dist/ts/src/hydration.d.ts.map +1 -0
- package/dist/ts/src/hydration.js +5 -0
- package/dist/ts/src/hydration.js.map +1 -0
- package/dist/ts/src/index.d.ts +21 -0
- package/dist/ts/src/index.d.ts.map +1 -0
- package/dist/ts/src/index.js +45 -0
- package/dist/ts/src/index.js.map +1 -0
- package/dist/ts/src/internal/declared-collections.d.ts +30 -0
- package/dist/ts/src/internal/declared-collections.d.ts.map +1 -0
- package/dist/ts/src/internal/declared-collections.js +84 -0
- package/dist/ts/src/internal/declared-collections.js.map +1 -0
- package/dist/ts/src/internal/page-collection-schema.d.ts +44 -0
- package/dist/ts/src/internal/page-collection-schema.d.ts.map +1 -0
- package/dist/ts/src/internal/page-collection-schema.js +152 -0
- package/dist/ts/src/internal/page-collection-schema.js.map +1 -0
- package/dist/ts/src/lib/content-config-guard.d.ts +11 -0
- package/dist/ts/src/lib/content-config-guard.d.ts.map +1 -0
- package/dist/ts/src/lib/content-config-guard.js +41 -0
- package/dist/ts/src/lib/content-config-guard.js.map +1 -0
- package/dist/ts/src/lib/hydration-scanner.d.ts +47 -0
- package/dist/ts/src/lib/hydration-scanner.d.ts.map +1 -0
- package/dist/ts/src/lib/hydration-scanner.js +136 -0
- package/dist/ts/src/lib/hydration-scanner.js.map +1 -0
- package/dist/{lib/hydration-script.d.mts → ts/src/lib/hydration-script.d.ts} +7 -10
- package/dist/ts/src/lib/hydration-script.d.ts.map +1 -0
- package/dist/ts/src/lib/hydration-script.js +89 -0
- package/dist/ts/src/lib/hydration-script.js.map +1 -0
- package/dist/ts/src/lib/hydration-utils.d.ts +51 -0
- package/dist/ts/src/lib/hydration-utils.d.ts.map +1 -0
- package/dist/ts/src/lib/hydration-utils.js +84 -0
- package/dist/ts/src/lib/hydration-utils.js.map +1 -0
- package/dist/ts/src/lib/resolve-locale.d.ts +15 -0
- package/dist/ts/src/lib/resolve-locale.d.ts.map +1 -0
- package/dist/ts/src/lib/resolve-locale.js +16 -0
- package/dist/ts/src/lib/resolve-locale.js.map +1 -0
- package/dist/ts/src/lib/resolve-site-name.d.ts +8 -0
- package/dist/ts/src/lib/resolve-site-name.d.ts.map +1 -0
- package/dist/ts/src/lib/resolve-site-name.js +12 -0
- package/dist/ts/src/lib/resolve-site-name.js.map +1 -0
- package/dist/ts/src/lib/route-utils.d.ts +61 -0
- package/dist/ts/src/lib/route-utils.d.ts.map +1 -0
- package/dist/ts/src/lib/route-utils.js +96 -0
- package/dist/ts/src/lib/route-utils.js.map +1 -0
- package/dist/ts/src/lib/routing-config.d.ts +38 -0
- package/dist/ts/src/lib/routing-config.d.ts.map +1 -0
- package/dist/ts/src/lib/routing-config.js +106 -0
- package/dist/ts/src/lib/routing-config.js.map +1 -0
- package/dist/ts/src/lib/serialize-props.d.ts +6 -0
- package/dist/ts/src/lib/serialize-props.d.ts.map +1 -0
- package/dist/ts/src/lib/serialize-props.js +8 -0
- package/dist/ts/src/lib/serialize-props.js.map +1 -0
- package/dist/ts/src/lib/unknown-components.d.ts +21 -0
- package/dist/ts/src/lib/unknown-components.d.ts.map +1 -0
- package/dist/ts/src/lib/unknown-components.js +49 -0
- package/dist/ts/src/lib/unknown-components.js.map +1 -0
- package/dist/ts/src/lib/virtual-module-generators.d.ts +33 -0
- package/dist/ts/src/lib/virtual-module-generators.d.ts.map +1 -0
- package/dist/ts/src/lib/virtual-module-generators.js +51 -0
- package/dist/ts/src/lib/virtual-module-generators.js.map +1 -0
- package/dist/{withHydration-HIvO9ysY.d.mts → ts/src/lib/withHydration.d.ts} +7 -11
- package/dist/ts/src/lib/withHydration.d.ts.map +1 -0
- package/dist/ts/src/lib/withHydration.js +50 -0
- package/dist/ts/src/lib/withHydration.js.map +1 -0
- package/dist/ts/src/loader.d.ts +27 -0
- package/dist/ts/src/loader.d.ts.map +1 -0
- package/dist/ts/src/loader.js +118 -0
- package/dist/ts/src/loader.js.map +1 -0
- package/dist/ts/src/locales-helpers.d.ts +61 -0
- package/dist/ts/src/locales-helpers.d.ts.map +1 -0
- package/dist/ts/src/locales-helpers.js +50 -0
- package/dist/ts/src/locales-helpers.js.map +1 -0
- package/dist/ts/src/mime-types.d.ts +3 -0
- package/dist/ts/src/mime-types.d.ts.map +1 -0
- package/dist/ts/src/mime-types.js +20 -0
- package/dist/ts/src/mime-types.js.map +1 -0
- package/dist/ts/src/page-feed.d.ts +13 -0
- package/dist/ts/src/page-feed.d.ts.map +1 -0
- package/dist/ts/src/page-feed.js +20 -0
- package/dist/ts/src/page-feed.js.map +1 -0
- package/dist/ts/src/page-schemas.d.ts +6 -0
- package/dist/ts/src/page-schemas.d.ts.map +1 -0
- package/dist/ts/src/page-schemas.js +6 -0
- package/dist/ts/src/page-schemas.js.map +1 -0
- package/dist/ts/src/path-validation.d.ts +8 -0
- package/dist/ts/src/path-validation.d.ts.map +1 -0
- package/dist/ts/src/path-validation.js +13 -0
- package/dist/ts/src/path-validation.js.map +1 -0
- package/dist/ts/src/plugin-spa.d.ts +182 -0
- package/dist/ts/src/plugin-spa.d.ts.map +1 -0
- package/dist/ts/src/plugin-spa.js +1165 -0
- package/dist/ts/src/plugin-spa.js.map +1 -0
- package/dist/ts/src/puck-manifest/components-endpoint.d.ts +30 -0
- package/dist/ts/src/puck-manifest/components-endpoint.d.ts.map +1 -0
- package/dist/ts/src/puck-manifest/components-endpoint.js +54 -0
- package/dist/ts/src/puck-manifest/components-endpoint.js.map +1 -0
- package/dist/ts/src/puck-manifest/field-projection.d.ts +91 -0
- package/dist/ts/src/puck-manifest/field-projection.d.ts.map +1 -0
- package/dist/ts/src/puck-manifest/field-projection.js +422 -0
- package/dist/ts/src/puck-manifest/field-projection.js.map +1 -0
- package/dist/ts/src/puck-manifest/index.d.ts +4 -0
- package/dist/ts/src/puck-manifest/index.d.ts.map +1 -0
- package/dist/ts/src/puck-manifest/index.js +3 -0
- package/dist/ts/src/puck-manifest/index.js.map +1 -0
- package/dist/ts/src/puck-manifest/literal.d.ts +163 -0
- package/dist/ts/src/puck-manifest/literal.d.ts.map +1 -0
- package/dist/ts/src/puck-manifest/literal.js +354 -0
- package/dist/ts/src/puck-manifest/literal.js.map +1 -0
- package/dist/ts/src/puck-manifest/read-config.d.ts +42 -0
- package/dist/ts/src/puck-manifest/read-config.d.ts.map +1 -0
- package/dist/ts/src/puck-manifest/read-config.js +517 -0
- package/dist/ts/src/puck-manifest/read-config.js.map +1 -0
- package/dist/ts/src/puck-manifest/read-field.d.ts +7 -0
- package/dist/ts/src/puck-manifest/read-field.d.ts.map +1 -0
- package/dist/ts/src/puck-manifest/read-field.js +11 -0
- package/dist/ts/src/puck-manifest/read-field.js.map +1 -0
- package/dist/ts/src/puck-manifest/read-wrapper.d.ts +147 -0
- package/dist/ts/src/puck-manifest/read-wrapper.d.ts.map +1 -0
- package/dist/ts/src/puck-manifest/read-wrapper.js +889 -0
- package/dist/ts/src/puck-manifest/read-wrapper.js.map +1 -0
- package/dist/ts/src/puck-manifest/reading-budget.d.ts +50 -0
- package/dist/ts/src/puck-manifest/reading-budget.d.ts.map +1 -0
- package/dist/ts/src/puck-manifest/reading-budget.js +113 -0
- package/dist/ts/src/puck-manifest/reading-budget.js.map +1 -0
- package/dist/ts/src/puck-manifest/resolve-reference.d.ts +4 -0
- package/dist/ts/src/puck-manifest/resolve-reference.d.ts.map +1 -0
- package/dist/ts/src/puck-manifest/resolve-reference.js +4 -0
- package/dist/ts/src/puck-manifest/resolve-reference.js.map +1 -0
- package/dist/ts/src/puck-manifest/source-reference.d.ts +96 -0
- package/dist/ts/src/puck-manifest/source-reference.d.ts.map +1 -0
- package/dist/ts/src/puck-manifest/source-reference.js +424 -0
- package/dist/ts/src/puck-manifest/source-reference.js.map +1 -0
- package/dist/ts/src/puck-manifest/syntax.d.ts +29 -0
- package/dist/ts/src/puck-manifest/syntax.d.ts.map +1 -0
- package/dist/ts/src/puck-manifest/syntax.js +79 -0
- package/dist/ts/src/puck-manifest/syntax.js.map +1 -0
- package/dist/ts/src/puck-manifest/types.d.ts +145 -0
- package/dist/ts/src/puck-manifest/types.d.ts.map +1 -0
- package/dist/ts/src/puck-manifest/types.js +2 -0
- package/dist/ts/src/puck-manifest/types.js.map +1 -0
- package/dist/ts/src/safe-json-stringify.d.ts +13 -0
- package/dist/ts/src/safe-json-stringify.d.ts.map +1 -0
- package/dist/ts/src/safe-json-stringify.js +7 -0
- package/dist/ts/src/safe-json-stringify.js.map +1 -0
- package/dist/ts/src/sandbox-frame-handler.d.ts +19 -0
- package/dist/ts/src/sandbox-frame-handler.d.ts.map +1 -0
- package/dist/ts/src/sandbox-frame-handler.js +27 -0
- package/dist/ts/src/sandbox-frame-handler.js.map +1 -0
- package/dist/ts/src/site-styles/content-wrapper-endpoint.d.ts +73 -0
- package/dist/ts/src/site-styles/content-wrapper-endpoint.d.ts.map +1 -0
- package/dist/ts/src/site-styles/content-wrapper-endpoint.js +224 -0
- package/dist/ts/src/site-styles/content-wrapper-endpoint.js.map +1 -0
- package/dist/ts/src/site-styles/render-endpoint.d.ts +50 -0
- package/dist/ts/src/site-styles/render-endpoint.d.ts.map +1 -0
- package/dist/ts/src/site-styles/render-endpoint.js +264 -0
- package/dist/ts/src/site-styles/render-endpoint.js.map +1 -0
- package/dist/ts/src/site-styles/styles-endpoint.d.ts +59 -0
- package/dist/ts/src/site-styles/styles-endpoint.d.ts.map +1 -0
- package/dist/ts/src/site-styles/styles-endpoint.js +156 -0
- package/dist/ts/src/site-styles/styles-endpoint.js.map +1 -0
- package/dist/ts/src/sitemap-options.d.ts +21 -0
- package/dist/ts/src/sitemap-options.d.ts.map +1 -0
- package/dist/ts/src/sitemap-options.js +92 -0
- package/dist/ts/src/sitemap-options.js.map +1 -0
- package/dist/ts/src/tiptap-html-static.d.ts +15 -0
- package/dist/ts/src/tiptap-html-static.d.ts.map +1 -0
- package/dist/ts/src/tiptap-html-static.js +67 -0
- package/dist/ts/src/tiptap-html-static.js.map +1 -0
- package/dist/ts/src/types.d.ts +543 -0
- package/dist/ts/src/types.d.ts.map +1 -0
- package/dist/ts/src/types.js +2 -0
- package/dist/ts/src/types.js.map +1 -0
- package/dist/virtual-modules.d.ts +74 -0
- package/node/content.ts +14 -0
- package/node/index.ts +22 -0
- package/package.json +198 -56
- package/src/asset-ref-base.ts +48 -0
- package/src/checks.ts +10 -0
- package/src/cms-handler.ts +280 -0
- package/src/collections.ts +262 -0
- package/src/components/HydrationWrapper.tsx +41 -0
- package/src/components/RenderWithFragments.tsx +204 -0
- package/src/components/RenderWithHydration.tsx +55 -0
- package/src/components.ts +3 -0
- package/src/discovery/astro-frontmatter.ts +24 -0
- package/src/discovery/discover.ts +108 -0
- package/src/discovery/extract-props-ts.ts +255 -0
- package/src/discovery/merge-registry.ts +411 -0
- package/src/discovery/registry-endpoint.ts +80 -0
- package/src/discovery/scan-components.ts +458 -0
- package/src/discovery/scan-mdx.ts +190 -0
- package/src/discovery/scan-overrides.ts +92 -0
- package/src/editor-descriptors.ts +96 -0
- package/src/env.d.ts +31 -0
- package/src/handlers/collection-content-api.ts +196 -0
- package/src/handlers/page-handler.astro +320 -0
- package/src/handlers/page-render-core.ts +456 -0
- package/src/hydration.ts +7 -0
- package/src/index.ts +111 -0
- package/src/internal/acorn-default.mjs +37 -0
- package/src/internal/declared-collections.ts +98 -0
- package/src/internal/page-collection-schema.ts +210 -0
- package/src/lib/content-config-guard.ts +48 -0
- package/src/lib/hydration-scanner.ts +176 -0
- package/src/lib/hydration-script.ts +126 -0
- package/src/lib/hydration-utils.ts +120 -0
- package/src/lib/resolve-locale.ts +22 -0
- package/src/lib/resolve-site-name.ts +10 -0
- package/src/lib/route-utils.ts +106 -0
- package/src/lib/routing-config.ts +126 -0
- package/src/lib/serialize-props.ts +7 -0
- package/src/lib/unknown-components.ts +64 -0
- package/src/lib/virtual-module-generators.ts +58 -0
- package/src/lib/withHydration.ts +71 -0
- package/src/loader.ts +145 -0
- package/src/locales-helpers.ts +68 -0
- package/src/mime-types.ts +19 -0
- package/src/page-feed.ts +26 -0
- package/src/page-schemas.ts +19 -0
- package/src/path-validation.ts +13 -0
- package/src/plugin-spa.ts +1480 -0
- package/src/puck-manifest/components-endpoint.ts +55 -0
- package/src/puck-manifest/field-projection.ts +510 -0
- package/src/puck-manifest/index.ts +3 -0
- package/src/puck-manifest/literal.ts +459 -0
- package/src/puck-manifest/read-config.ts +577 -0
- package/src/puck-manifest/read-field.ts +19 -0
- package/src/puck-manifest/read-wrapper.ts +1056 -0
- package/src/puck-manifest/reading-budget.ts +127 -0
- package/src/puck-manifest/resolve-reference.ts +9 -0
- package/src/puck-manifest/source-reference.ts +484 -0
- package/src/puck-manifest/syntax.ts +104 -0
- package/src/puck-manifest/types.ts +139 -0
- package/src/safe-json-stringify.ts +17 -0
- package/src/sandbox-frame-handler.ts +31 -0
- package/src/site-styles/content-wrapper-endpoint.ts +327 -0
- package/src/site-styles/render-endpoint.ts +331 -0
- package/src/site-styles/styles-endpoint.ts +184 -0
- package/src/sitemap-options.ts +115 -0
- package/src/tiptap-html-static.ts +84 -0
- package/{dist/types-CVQNmPxF.d.mts → src/types.ts} +232 -79
- package/src/virtual-modules.d.ts +74 -0
- package/dist/collections.d.mts +0 -36
- package/dist/collections.d.mts.map +0 -1
- package/dist/collections.mjs +0 -65
- package/dist/collections.mjs.map +0 -1
- package/dist/components.d.mts +0 -46
- package/dist/components.d.mts.map +0 -1
- package/dist/components.mjs +0 -226
- package/dist/components.mjs.map +0 -1
- package/dist/hydration-scanner-B0NjYkZ_.mjs +0 -109
- package/dist/hydration-scanner-B0NjYkZ_.mjs.map +0 -1
- package/dist/hydration.d.mts +0 -4
- package/dist/hydration.mjs +0 -3
- package/dist/index.d.mts +0 -139
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -66
- package/dist/index.mjs.map +0 -1
- package/dist/internal/cms-handler.d.mts +0 -26
- package/dist/internal/cms-handler.d.mts.map +0 -1
- package/dist/internal/cms-handler.mjs +0 -267
- package/dist/internal/cms-handler.mjs.map +0 -1
- package/dist/lib/hydration-script.d.mts.map +0 -1
- package/dist/lib/hydration-script.mjs +0 -85
- package/dist/lib/hydration-script.mjs.map +0 -1
- package/dist/loader-By-AQWHc.mjs +0 -68
- package/dist/loader-By-AQWHc.mjs.map +0 -1
- package/dist/node/content.d.mts +0 -19
- package/dist/node/content.d.mts.map +0 -1
- package/dist/node/content.mjs +0 -4
- package/dist/node/index.d.mts +0 -52
- package/dist/node/index.d.mts.map +0 -1
- package/dist/node/index.mjs +0 -753
- package/dist/node/index.mjs.map +0 -1
- package/dist/serialize-props-Dhv_MnkY.mjs +0 -73
- package/dist/serialize-props-Dhv_MnkY.mjs.map +0 -1
- package/dist/types-CVQNmPxF.d.mts.map +0 -1
- package/dist/withHydration-EzyzBQ-Y.mjs +0 -49
- package/dist/withHydration-EzyzBQ-Y.mjs.map +0 -1
- package/dist/withHydration-HIvO9ysY.d.mts.map +0 -1
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Astro-free render core for the page handler.
|
|
3
|
+
*
|
|
4
|
+
* The pure frontmatter logic of `page-handler.astro` (entry shaping/filtering,
|
|
5
|
+
* data context assembly, puck-data resolution, MDX fragment loading) lives here,
|
|
6
|
+
* parameterized over a narrow {@link PageContentSource} so the same logic runs
|
|
7
|
+
* against two backends: Astro content collections, and a ContentAPI reader a
|
|
8
|
+
* caller installs on `Astro.locals.contentApi`. No `astro:content` import and
|
|
9
|
+
* no `import.meta.env` — the `.astro` file injects `getCollection` (via
|
|
10
|
+
* {@link createCollectionContentSource}) and the dev flag, so this module is
|
|
11
|
+
* importable outside an Astro page.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { mergeDefaultProps } from '@conloca/cms-spa/merge-default-props';
|
|
15
|
+
import {
|
|
16
|
+
type ContentAPI,
|
|
17
|
+
type ContentManifest,
|
|
18
|
+
type ContentMeta,
|
|
19
|
+
isContentPublished,
|
|
20
|
+
type MDXHeading,
|
|
21
|
+
pageTimestampsOf,
|
|
22
|
+
selectPagesByPrefix,
|
|
23
|
+
} from '@conloca/content-api';
|
|
24
|
+
import type { Config } from '@puckeditor/core';
|
|
25
|
+
import { type Data, resolveAllData } from '@puckeditor/core';
|
|
26
|
+
import type { ComponentType } from 'react';
|
|
27
|
+
import React from 'react';
|
|
28
|
+
import type { DataCollectionEntry, DataContext, PageReference, ResolvedRoutingConfig } from '../types.js';
|
|
29
|
+
|
|
30
|
+
// Re-exported so the copied `dist/internal/page-handler.astro` reaches
|
|
31
|
+
// everything it renders with through this one module.
|
|
32
|
+
export { findUnknownComponentTypes } from '../lib/unknown-components.js';
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Synthetic collection every discovered fragment lands in (the loader flattens
|
|
36
|
+
* all fragment collections into one). Owned here — rather than imported from
|
|
37
|
+
* `collections.ts` — so this core stays free of the `astro:content` that module
|
|
38
|
+
* pulls in; `collections.ts` re-exports it to keep the public name stable.
|
|
39
|
+
*/
|
|
40
|
+
export const ALL_FRAGMENTS_COLLECTION = '__conloca_fragments';
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The single content-access seam the render core depends on: give me the raw
|
|
44
|
+
* frontmatter data records for a collection. The collection-backed impl wraps
|
|
45
|
+
* Astro's `getCollection`; the reader-backed impl (preview) projects
|
|
46
|
+
* ContentAPI content into the same record shape.
|
|
47
|
+
*/
|
|
48
|
+
export interface PageContentSource {
|
|
49
|
+
listEntries(collection: string): Promise<Record<string, unknown>[]>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
interface BaseEntryData {
|
|
53
|
+
id: string;
|
|
54
|
+
locale: string;
|
|
55
|
+
title?: string;
|
|
56
|
+
description?: string;
|
|
57
|
+
created?: string | Date;
|
|
58
|
+
modified?: string | Date;
|
|
59
|
+
publishAt?: string | Date | null;
|
|
60
|
+
unpublishAt?: string | Date | null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface PageEntryData extends BaseEntryData {
|
|
64
|
+
pathname?: string;
|
|
65
|
+
puckData?: Data;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* A page entry as the content loader delivers it: the structural fields above
|
|
70
|
+
* plus the host page schema's meta fields flattened alongside them.
|
|
71
|
+
*/
|
|
72
|
+
export type PageEntryRecord = PageEntryData & Record<string, unknown>;
|
|
73
|
+
|
|
74
|
+
interface FragmentEntryData extends BaseEntryData {
|
|
75
|
+
name?: string;
|
|
76
|
+
mdx?: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
interface DataEntryData extends BaseEntryData {
|
|
80
|
+
name?: string;
|
|
81
|
+
data?: Record<string, unknown>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** An evaluated MDX fragment ready to render, matching RenderWithFragments' shape. */
|
|
85
|
+
export interface MdxFragmentComponent {
|
|
86
|
+
id: string;
|
|
87
|
+
title: string;
|
|
88
|
+
Component: ComponentType;
|
|
89
|
+
outline: readonly MDXHeading[];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
type EvaluateMDXToComponentFn = typeof import('@conloca/mdx/node')['evaluateMDXToComponent'];
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Collection-backed {@link PageContentSource}. The production render path
|
|
96
|
+
* injects Astro's `getCollection`; the dev flag preserves the handler's
|
|
97
|
+
* cache-bypass-in-DEV behaviour and the per-render dedup cache. Kept identical
|
|
98
|
+
* to the handler's former inline `loadCollectionEntries`/`getCollectionEntries`
|
|
99
|
+
* so the built page HTML is byte-for-byte unchanged.
|
|
100
|
+
*/
|
|
101
|
+
export function createCollectionContentSource(deps: {
|
|
102
|
+
getCollection: (collection: string) => Promise<{ data: unknown }[]>;
|
|
103
|
+
isDev: boolean;
|
|
104
|
+
}): PageContentSource {
|
|
105
|
+
const collectionCache = new Map<string, Promise<{ data: unknown }[]>>();
|
|
106
|
+
|
|
107
|
+
async function getCollectionEntries(collectionName: string) {
|
|
108
|
+
return deps.getCollection(collectionName).catch((error) => {
|
|
109
|
+
if (
|
|
110
|
+
error instanceof Error &&
|
|
111
|
+
error.message.includes(`The collection "${collectionName}" does not exist or is empty`)
|
|
112
|
+
) {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
throw error;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async function loadCollectionEntries(collectionName: string) {
|
|
121
|
+
if (deps.isDev) {
|
|
122
|
+
return getCollectionEntries(collectionName);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
let entriesPromise = collectionCache.get(collectionName);
|
|
126
|
+
|
|
127
|
+
if (!entriesPromise) {
|
|
128
|
+
entriesPromise = getCollectionEntries(collectionName);
|
|
129
|
+
collectionCache.set(collectionName, entriesPromise);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return entriesPromise;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
async listEntries(collection) {
|
|
137
|
+
const entries = await loadCollectionEntries(collection);
|
|
138
|
+
return entries.map((entry) => entry.data as Record<string, unknown>);
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Canonical pathname form: no trailing slash, except the root itself. Site
|
|
145
|
+
* nav links carry trailing slashes ('/faq/') while entry pathnames are
|
|
146
|
+
* canonical ('/faq'); every exact-equality match must go through this.
|
|
147
|
+
*/
|
|
148
|
+
export function normalizePathname(pathname: string): string {
|
|
149
|
+
const stripped = pathname.replace(/\/+$/u, '');
|
|
150
|
+
return stripped === '' ? '/' : stripped;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Response for a matched route whose content lookup found nothing. The
|
|
155
|
+
* 'passthrough' body is deliberately null: Astro only reroutes a 404 to the
|
|
156
|
+
* site's own /404 route when the body is empty, and that reroute serves even a
|
|
157
|
+
* prerendered /404 page with a real 404 status — so the site keeps its designed
|
|
158
|
+
* not-found page without a soft-404 redirect.
|
|
159
|
+
*/
|
|
160
|
+
export function pageNotFoundResponse(fallback: '404' | 'passthrough'): Response {
|
|
161
|
+
if (fallback === 'passthrough') {
|
|
162
|
+
return new Response(null, { status: 404 });
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return new Response('Page not found', { status: 404 });
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Runtime narrow from a raw loader record to a page entry. Checks the fields
|
|
170
|
+
* a {@link PageReference} is built from, so nothing downstream carries a type
|
|
171
|
+
* the record never had — a record without a string id is dropped here instead
|
|
172
|
+
* of becoming a PageReference whose `id: string` is a lie.
|
|
173
|
+
*/
|
|
174
|
+
function isPageEntryRecord(data: Record<string, unknown>): data is PageEntryRecord & { pathname: string } {
|
|
175
|
+
return typeof data.id === 'string' && typeof data.locale === 'string' && typeof data.pathname === 'string';
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Published page entries for a collection/locale, shaped for downstream use.
|
|
180
|
+
* The narrowing `isPageEntryRecord` performs is kept in the return type, so
|
|
181
|
+
* callers read `pathname` as the string the filter already guaranteed.
|
|
182
|
+
*/
|
|
183
|
+
export async function getPageEntries(
|
|
184
|
+
source: PageContentSource,
|
|
185
|
+
collectionName: string,
|
|
186
|
+
locale: string,
|
|
187
|
+
): Promise<(PageEntryRecord & { pathname: string })[]> {
|
|
188
|
+
const entries = await source.listEntries(collectionName);
|
|
189
|
+
|
|
190
|
+
return entries.filter(isPageEntryRecord).filter((data) => data.locale === locale && isContentPublished(data));
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function toPageReference(entry: PageEntryRecord, collection: string): PageReference {
|
|
194
|
+
// The content loader flattens localeVersion.meta into the entry record, so
|
|
195
|
+
// everything that isn't a structural field IS the page's metadata: the rest
|
|
196
|
+
// element peels the structural fields off rather than allowlisting meta
|
|
197
|
+
// keys — host page schemas add arbitrary fields (author, tags, …) that
|
|
198
|
+
// listing components read via `page.meta`, and the editor's page feed
|
|
199
|
+
// (`pageReferenceOf`) passes the full meta; the rendered site must match it.
|
|
200
|
+
const { id, locale, pathname, name, created, modified, publishAt, unpublishAt, puckData, mdx, data, ...rest } = entry;
|
|
201
|
+
// `pageMetaSchema` makes `title` required, so a page that reached the
|
|
202
|
+
// collection carries one; the loader-record type marks it optional because it
|
|
203
|
+
// describes the raw flattened shape, before that schema runs. Assert the
|
|
204
|
+
// narrower ContentMeta here rather than inventing an empty title downstream.
|
|
205
|
+
const meta = rest as ContentMeta;
|
|
206
|
+
|
|
207
|
+
return {
|
|
208
|
+
id,
|
|
209
|
+
pathname: pathname || '/',
|
|
210
|
+
title: meta.title,
|
|
211
|
+
collection,
|
|
212
|
+
meta,
|
|
213
|
+
timestamps: pageTimestampsOf({ created, modified, publishAt }),
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export async function getPagesByPrefix(
|
|
218
|
+
source: PageContentSource,
|
|
219
|
+
prefix: string,
|
|
220
|
+
locale: string,
|
|
221
|
+
config: ResolvedRoutingConfig,
|
|
222
|
+
options?: { sort?: 'date-desc' | 'date-asc' | 'title'; limit?: number },
|
|
223
|
+
): Promise<PageReference[]> {
|
|
224
|
+
const pageCollections = Array.from(new Set(Object.values(config.routes).map((route) => route.collection)));
|
|
225
|
+
const pages = (
|
|
226
|
+
await Promise.all(
|
|
227
|
+
pageCollections.map(async (collectionName) => {
|
|
228
|
+
const entries = await getPageEntries(source, collectionName, locale);
|
|
229
|
+
|
|
230
|
+
return entries.map((data) => toPageReference(data, collectionName));
|
|
231
|
+
}),
|
|
232
|
+
)
|
|
233
|
+
).flat();
|
|
234
|
+
|
|
235
|
+
return selectPagesByPrefix(pages, prefix, options);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export async function getDataCollectionEntries(
|
|
239
|
+
source: PageContentSource,
|
|
240
|
+
collectionName: string,
|
|
241
|
+
locale: string,
|
|
242
|
+
): Promise<DataCollectionEntry[]> {
|
|
243
|
+
const entries = await source.listEntries(collectionName);
|
|
244
|
+
|
|
245
|
+
return entries
|
|
246
|
+
.map((data) => data as Partial<DataEntryData>)
|
|
247
|
+
.filter((data) => data.locale === locale && typeof data.name === 'string' && isContentPublished(data))
|
|
248
|
+
.map((data) => ({
|
|
249
|
+
id: data.id || '',
|
|
250
|
+
name: data.name || '',
|
|
251
|
+
data: data.data || {},
|
|
252
|
+
meta: {
|
|
253
|
+
title: data.title,
|
|
254
|
+
description: data.description,
|
|
255
|
+
},
|
|
256
|
+
})) satisfies DataCollectionEntry[];
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Evaluate every published MDX fragment for a locale into a renderable React
|
|
261
|
+
* component. `evaluateMDXToComponent` and `isDev` are injected so the core
|
|
262
|
+
* stays astro/vite-free.
|
|
263
|
+
*/
|
|
264
|
+
export async function loadMdxComponents(
|
|
265
|
+
source: PageContentSource,
|
|
266
|
+
locale: string,
|
|
267
|
+
evaluateMDXToComponent: EvaluateMDXToComponentFn,
|
|
268
|
+
isDev: boolean,
|
|
269
|
+
): Promise<MdxFragmentComponent[]> {
|
|
270
|
+
const entries = (await source.listEntries(ALL_FRAGMENTS_COLLECTION)).map(
|
|
271
|
+
(data) => data as Partial<FragmentEntryData>,
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
return Promise.all(
|
|
275
|
+
entries
|
|
276
|
+
.filter(
|
|
277
|
+
(data): data is Partial<FragmentEntryData> & { id: string } =>
|
|
278
|
+
data.locale === locale && typeof data.id === 'string' && isContentPublished(data),
|
|
279
|
+
)
|
|
280
|
+
.map(async (data) => {
|
|
281
|
+
const title = data.title || data.name || data.id;
|
|
282
|
+
const mdx = data.mdx;
|
|
283
|
+
|
|
284
|
+
if (!mdx) {
|
|
285
|
+
if (isDev) {
|
|
286
|
+
console.warn(`[Conloca] No MDX content found for fragment: ${title}`);
|
|
287
|
+
}
|
|
288
|
+
return {
|
|
289
|
+
id: data.id || title,
|
|
290
|
+
title,
|
|
291
|
+
Component: () => null,
|
|
292
|
+
outline: [],
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const { Component, error, outline } = await evaluateMDXToComponent(mdx);
|
|
297
|
+
|
|
298
|
+
if (!Component || error) {
|
|
299
|
+
const errorMessage = error?.message || 'MDX evaluation failed';
|
|
300
|
+
console.error(`[Conloca] MDX compilation error in fragment "${title}": ${errorMessage}`);
|
|
301
|
+
|
|
302
|
+
return {
|
|
303
|
+
id: data.id || title,
|
|
304
|
+
title,
|
|
305
|
+
Component: isDev
|
|
306
|
+
? () =>
|
|
307
|
+
React.createElement(
|
|
308
|
+
'div',
|
|
309
|
+
{ className: 'p-4 bg-red-50 border border-red-200 rounded text-red-600' },
|
|
310
|
+
React.createElement('p', { className: 'font-semibold mb-2' }, 'MDX Compilation Error'),
|
|
311
|
+
React.createElement('p', { className: 'text-sm' }, `Fragment: ${title}`),
|
|
312
|
+
React.createElement('p', { className: 'text-xs mt-2' }, errorMessage),
|
|
313
|
+
)
|
|
314
|
+
: () => null,
|
|
315
|
+
outline: [],
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
return {
|
|
320
|
+
id: data.id || title,
|
|
321
|
+
title,
|
|
322
|
+
Component,
|
|
323
|
+
outline,
|
|
324
|
+
};
|
|
325
|
+
}),
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Assemble the data context every block of `entry` is rendered with: the page
|
|
331
|
+
* itself, plus the collections and pages-by-prefix its route's data bindings
|
|
332
|
+
* declare.
|
|
333
|
+
*/
|
|
334
|
+
export async function buildDataContext(
|
|
335
|
+
source: PageContentSource,
|
|
336
|
+
routeConfig: ResolvedRoutingConfig['routes'][string],
|
|
337
|
+
config: ResolvedRoutingConfig,
|
|
338
|
+
entry: PageEntryRecord & { pathname: string },
|
|
339
|
+
): Promise<DataContext> {
|
|
340
|
+
const dataBindings = routeConfig.dataBindings;
|
|
341
|
+
const collectionNames = dataBindings.collections;
|
|
342
|
+
const pagesConfig = dataBindings.pages;
|
|
343
|
+
const hasCollections = collectionNames !== undefined && collectionNames.length > 0;
|
|
344
|
+
const hasPages = pagesConfig?.prefix !== undefined && pagesConfig.prefix !== '';
|
|
345
|
+
|
|
346
|
+
const bindingsLocale = dataBindings.locale ?? config.locale;
|
|
347
|
+
const collections: Record<string, DataCollectionEntry[]> = {};
|
|
348
|
+
let pages: PageReference[] | undefined;
|
|
349
|
+
|
|
350
|
+
if (hasCollections) {
|
|
351
|
+
for (const collectionName of collectionNames) {
|
|
352
|
+
try {
|
|
353
|
+
collections[collectionName] = await getDataCollectionEntries(source, collectionName, bindingsLocale);
|
|
354
|
+
} catch (error) {
|
|
355
|
+
console.error(`[Conloca] Failed to fetch collection '${collectionName}':`, error);
|
|
356
|
+
collections[collectionName] = [];
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
if (hasPages && pagesConfig) {
|
|
362
|
+
try {
|
|
363
|
+
pages = await getPagesByPrefix(source, pagesConfig.prefix, bindingsLocale, config, {
|
|
364
|
+
sort: pagesConfig.sort,
|
|
365
|
+
limit: pagesConfig.limit,
|
|
366
|
+
});
|
|
367
|
+
} catch (error) {
|
|
368
|
+
console.error(`[Conloca] Failed to fetch pages with prefix '${pagesConfig.prefix}':`, error);
|
|
369
|
+
pages = [];
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
return {
|
|
374
|
+
collections,
|
|
375
|
+
...(pages && { pages }),
|
|
376
|
+
locale: bindingsLocale,
|
|
377
|
+
siteName: config.siteName,
|
|
378
|
+
page: toPageReference(entry, routeConfig.collection),
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Resolve a page's Puck data for render: apply component defaultProps, then run
|
|
384
|
+
* Puck's async data-resolution with the data context as each resolver's
|
|
385
|
+
* `metadata`. Falls back to the merged (unresolved) data on a resolver error,
|
|
386
|
+
* matching the handler's former behaviour.
|
|
387
|
+
*/
|
|
388
|
+
export async function resolvePuckData(puckData: Data, puckConfig: Config, dataContext: DataContext): Promise<Data> {
|
|
389
|
+
const mergedData = mergeDefaultProps(puckData, puckConfig);
|
|
390
|
+
try {
|
|
391
|
+
return await resolveAllData(mergedData, puckConfig, dataContext);
|
|
392
|
+
} catch (error) {
|
|
393
|
+
console.error('[Conloca] resolveAllData failed:', error);
|
|
394
|
+
return mergedData;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Reader-backed {@link PageContentSource} over a {@link ContentAPI}, the one a
|
|
400
|
+
* caller installs on `Astro.locals.contentApi`. It projects the reader's
|
|
401
|
+
* manifest listing + per-locale content into the SAME record shape the
|
|
402
|
+
* collection-backed source (and the Astro loader) produce, so the render core
|
|
403
|
+
* is oblivious to which backend served it: the page shows whatever that
|
|
404
|
+
* reader returns.
|
|
405
|
+
*
|
|
406
|
+
* The synthetic `__conloca_fragments` collection is not a real ContentAPI
|
|
407
|
+
* collection (the loader flattens every fragment collection into it), so it maps
|
|
408
|
+
* to a `kind: 'fragment'` query; `type: 'mdx'` PAGES are skipped exactly as the
|
|
409
|
+
* loader skips them (they belong to an external renderer).
|
|
410
|
+
*/
|
|
411
|
+
export function createReaderContentSource(api: ContentAPI, renderLocale?: string): PageContentSource {
|
|
412
|
+
const filtersFor = (collection: string) =>
|
|
413
|
+
collection === ALL_FRAGMENTS_COLLECTION ? ({ kind: 'fragment' } as const) : { collection };
|
|
414
|
+
|
|
415
|
+
const shapeEntry = async (manifest: ContentManifest, locale: string): Promise<Record<string, unknown> | null> => {
|
|
416
|
+
const localeVersion = manifest.locales[locale];
|
|
417
|
+
if (!localeVersion) return null;
|
|
418
|
+
const localized = await api.getLocalized(manifest.id, locale);
|
|
419
|
+
const content = localized?.localized.content;
|
|
420
|
+
const record: Record<string, unknown> = {
|
|
421
|
+
id: manifest.id,
|
|
422
|
+
locale,
|
|
423
|
+
...(localeVersion.pathname !== undefined && { pathname: localeVersion.pathname }),
|
|
424
|
+
...(localeVersion.name !== undefined && { name: localeVersion.name }),
|
|
425
|
+
...localeVersion.meta,
|
|
426
|
+
created: localeVersion.created,
|
|
427
|
+
modified: localeVersion.modified,
|
|
428
|
+
publishAt: localeVersion.publishAt,
|
|
429
|
+
unpublishAt: localeVersion.unpublishAt,
|
|
430
|
+
...(content?.data !== undefined && { data: content.data }),
|
|
431
|
+
};
|
|
432
|
+
if (content?.mdx !== undefined) record.mdx = content.mdx;
|
|
433
|
+
if (content?.puckData !== undefined) record.puckData = content.puckData;
|
|
434
|
+
return record;
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
return {
|
|
438
|
+
async listEntries(collection) {
|
|
439
|
+
const records: Record<string, unknown>[] = [];
|
|
440
|
+
for (const manifest of api.listAllContent(filtersFor(collection))) {
|
|
441
|
+
// Mirror the loader's skip: `type: 'mdx'` pages are owned by an
|
|
442
|
+
// external renderer, not this puck-page handler.
|
|
443
|
+
if (manifest.kind === 'page' && manifest.type === 'mdx') continue;
|
|
444
|
+
// Every consumer filters records to one locale, and each shaped
|
|
445
|
+
// locale is one getLocalized read, so with a render locale known,
|
|
446
|
+
// shaping the others is wasted work.
|
|
447
|
+
for (const locale of Object.keys(manifest.locales)) {
|
|
448
|
+
if (renderLocale !== undefined && locale !== renderLocale) continue;
|
|
449
|
+
const record = await shapeEntry(manifest, locale);
|
|
450
|
+
if (record) records.push(record);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
return records;
|
|
454
|
+
},
|
|
455
|
+
};
|
|
456
|
+
}
|
package/src/hydration.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Browser-safe exports for @conloca/astro-cms
|
|
2
|
+
// This entry point contains ONLY code that can run in the browser.
|
|
3
|
+
// Import from '@conloca/astro-cms/client' in component files that need hydration.
|
|
4
|
+
|
|
5
|
+
export type { ComponentRegistry } from './lib/hydration-script.js';
|
|
6
|
+
export { type HydrationMeta, type WithHydrationStrategy, withHydration } from './lib/withHydration.js';
|
|
7
|
+
export type { HydrationStrategy } from './types.js';
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Astro integration for Conloca CMS
|
|
2
|
+
|
|
3
|
+
// MDX component registry plugin API — hosts use these to register JSX
|
|
4
|
+
// components (e.g. Starlight's Steps/Tabs/Card) with typed insert editors
|
|
5
|
+
// and opt-in auto-import injection. Runtime registry also wires through
|
|
6
|
+
// the schemasPath option; hosts export `mdxComponents` from the same file.
|
|
7
|
+
//
|
|
8
|
+
// `readStringAttribute` / `writeStringAttribute` are mdast-level helpers
|
|
9
|
+
// for hosts writing their own typed `Editor` components — controlled
|
|
10
|
+
// inputs against a string prop. Re-exported here so a host's editor file
|
|
11
|
+
// can pull everything it needs from one place.
|
|
12
|
+
export {
|
|
13
|
+
defineMdxComponents,
|
|
14
|
+
type MdxComponentDescriptor,
|
|
15
|
+
type MdxComponentInsertHint,
|
|
16
|
+
type MdxComponentProp,
|
|
17
|
+
type MdxComponents,
|
|
18
|
+
type MdxJsxComponentDescriptor,
|
|
19
|
+
type MdxSnippetDescriptor,
|
|
20
|
+
readStringAttribute,
|
|
21
|
+
writeStringAttribute,
|
|
22
|
+
} from '@conloca/cms-spa/mdx-components-define';
|
|
23
|
+
// Page-schema plugin API — hosts use these to declare frontmatter form UI
|
|
24
|
+
// for the CMS page-settings dialog. Runtime registry lives in @conloca/cms-spa
|
|
25
|
+
// and is wired by the schemasPath option (see ConlocaCMSOptions).
|
|
26
|
+
export {
|
|
27
|
+
type CoreFieldsMode,
|
|
28
|
+
definePageSchema,
|
|
29
|
+
type FieldHint,
|
|
30
|
+
type FieldHintCommon,
|
|
31
|
+
type FieldHints,
|
|
32
|
+
type FieldHintVariant,
|
|
33
|
+
type PageSchemaDescriptor,
|
|
34
|
+
type PageSchemaEntry,
|
|
35
|
+
type PageSchemaGroup,
|
|
36
|
+
type PageSchemas,
|
|
37
|
+
} from '@conloca/cms-spa/page-schema-define';
|
|
38
|
+
// Blocks mark the parts they render from the page's settings, so a click on
|
|
39
|
+
// the editor canvas opens Page settings at that field.
|
|
40
|
+
export {
|
|
41
|
+
type PageSettingAttributes,
|
|
42
|
+
type PageSettingName,
|
|
43
|
+
pageSettingAttributes,
|
|
44
|
+
} from '@conloca/cms-spa/page-setting-attributes';
|
|
45
|
+
// Re-export Zod schemas and types for convenience
|
|
46
|
+
export {
|
|
47
|
+
type FragmentMeta,
|
|
48
|
+
fragmentMetaSchema,
|
|
49
|
+
type PageMeta,
|
|
50
|
+
pageMetaSchema,
|
|
51
|
+
} from '@conloca/content-api/schemas';
|
|
52
|
+
// Read-only ContentAPI over the build's content collections.
|
|
53
|
+
export {
|
|
54
|
+
type CollectionBackedContentAPIOptions,
|
|
55
|
+
createCollectionBackedContentAPI,
|
|
56
|
+
} from './handlers/collection-content-api.js';
|
|
57
|
+
// `scanForHydratableComponents` lives in '@conloca/astro-cms/node' — it
|
|
58
|
+
// imports fast-glob and node:fs, which crash when this barrel is
|
|
59
|
+
// dynamic-imported in the browser (notably by the CMS SPA's schemas
|
|
60
|
+
// loader). Hosts that need it import from the /node subpath.
|
|
61
|
+
// Type-only export for sites that want to customize hydration
|
|
62
|
+
export type { ComponentRegistry } from './lib/hydration-script.js';
|
|
63
|
+
export {
|
|
64
|
+
findHydratableComponents,
|
|
65
|
+
type HydratableComponent,
|
|
66
|
+
type HydratableComponentConfig,
|
|
67
|
+
hasHydratableComponents,
|
|
68
|
+
isHydratable,
|
|
69
|
+
} from './lib/hydration-utils.js';
|
|
70
|
+
export {
|
|
71
|
+
entryIdFromPath,
|
|
72
|
+
extractSlugFromPathname,
|
|
73
|
+
isPublished,
|
|
74
|
+
pathnameFromSlug,
|
|
75
|
+
staticPathParams,
|
|
76
|
+
toDate,
|
|
77
|
+
} from './lib/route-utils.js';
|
|
78
|
+
export { serializeProps } from './lib/serialize-props.js';
|
|
79
|
+
// New hydration API: withHydration wrapper and build-time scanner
|
|
80
|
+
export { type HydrationMeta, type WithHydrationStrategy, withHydration } from './lib/withHydration.js';
|
|
81
|
+
// Locale plumbing helpers — translate framework-native i18n configs
|
|
82
|
+
// into Conloca's locale shape. See locales-helpers.ts for the contract.
|
|
83
|
+
export { type ConlocaLocales, localesFromAstroI18n, localesFromStarlight } from './locales-helpers.js';
|
|
84
|
+
// Hydration support for interactive components
|
|
85
|
+
// NOTE: The root entry point is intentionally static-safe.
|
|
86
|
+
// Node/Astro integration APIs live under '@conloca/astro-cms/node'.
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Migration stub: the integration moved to '@conloca/astro-cms/node' so the
|
|
90
|
+
* root entry stays static-safe. Published 0.1.x exported it from the root —
|
|
91
|
+
* without this stub those configs fail with an opaque "not a function".
|
|
92
|
+
*
|
|
93
|
+
* @deprecated Import { conlocaCMS } from '@conloca/astro-cms/node' instead.
|
|
94
|
+
*/
|
|
95
|
+
export function conlocaCMS(_options?: unknown): never {
|
|
96
|
+
throw new Error(
|
|
97
|
+
"conlocaCMS moved: import { conlocaCMS } from '@conloca/astro-cms/node'. " +
|
|
98
|
+
'The package root stays free of Node-only code so it can load in any runtime.',
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
export type {
|
|
102
|
+
ContentFragmentSectionProps,
|
|
103
|
+
DataCollectionEntry,
|
|
104
|
+
DataContext,
|
|
105
|
+
HydrationStrategy,
|
|
106
|
+
LayoutProps,
|
|
107
|
+
PageData,
|
|
108
|
+
PageReference,
|
|
109
|
+
ResolvedRoutingConfig,
|
|
110
|
+
TemplateConfig,
|
|
111
|
+
} from './types.js';
|
|
@@ -0,0 +1,37 @@
|
|
|
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';
|
|
10
|
+
|
|
11
|
+
// Bundler CJS interop can surface the namespace under `default`.
|
|
12
|
+
const acorn = acornModule.Parser ? acornModule : acornModule.default;
|
|
13
|
+
|
|
14
|
+
export const Node = acorn.Node;
|
|
15
|
+
export const Parser = acorn.Parser;
|
|
16
|
+
export const Position = acorn.Position;
|
|
17
|
+
export const SourceLocation = acorn.SourceLocation;
|
|
18
|
+
export const TokContext = acorn.TokContext;
|
|
19
|
+
export const Token = acorn.Token;
|
|
20
|
+
export const TokenType = acorn.TokenType;
|
|
21
|
+
export const defaultOptions = acorn.defaultOptions;
|
|
22
|
+
export const getLineInfo = acorn.getLineInfo;
|
|
23
|
+
export const isIdentifierChar = acorn.isIdentifierChar;
|
|
24
|
+
export const isIdentifierStart = acorn.isIdentifierStart;
|
|
25
|
+
export const isNewLine = acorn.isNewLine;
|
|
26
|
+
export const keywordTypes = acorn.keywordTypes;
|
|
27
|
+
export const lineBreak = acorn.lineBreak;
|
|
28
|
+
export const lineBreakG = acorn.lineBreakG;
|
|
29
|
+
export const nonASCIIwhitespace = acorn.nonASCIIwhitespace;
|
|
30
|
+
export const parse = acorn.parse;
|
|
31
|
+
export const parseExpressionAt = acorn.parseExpressionAt;
|
|
32
|
+
export const tokContexts = acorn.tokContexts;
|
|
33
|
+
export const tokTypes = acorn.tokTypes;
|
|
34
|
+
export const tokenizer = acorn.tokenizer;
|
|
35
|
+
export const version = acorn.version;
|
|
36
|
+
|
|
37
|
+
export default acorn;
|