@conloca/astro-cms 0.1.15 → 0.1.16
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 +65 -5
- package/dist/collections-Bd7EME4b.mjs +129 -0
- package/dist/collections-Bd7EME4b.mjs.map +1 -0
- package/dist/collections.d.mts +0 -1
- package/dist/collections.d.mts.map +1 -1
- package/dist/collections.mjs +1 -64
- package/dist/components.d.mts +2 -7
- package/dist/components.d.mts.map +1 -1
- package/dist/components.mjs +3 -6
- package/dist/components.mjs.map +1 -1
- package/dist/hydration.d.mts +2 -2
- package/dist/hydration.mjs +2 -3
- package/dist/index.d.mts +6 -37
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +7 -6
- package/dist/index.mjs.map +1 -1
- package/dist/internal/cms-handler.d.mts +0 -1
- package/dist/internal/cms-handler.d.mts.map +1 -1
- package/dist/internal/cms-handler.mjs +55 -8
- package/dist/internal/cms-handler.mjs.map +1 -1
- package/dist/lib/hydration-script.d.mts +1 -2
- package/dist/lib/hydration-script.d.mts.map +1 -1
- package/dist/lib/hydration-script.mjs +1 -2
- package/dist/lib/hydration-script.mjs.map +1 -1
- package/dist/locales-helpers-BvYYqnJ5.d.mts +64 -0
- package/dist/locales-helpers-BvYYqnJ5.d.mts.map +1 -0
- package/dist/locales-helpers-qiwh7nxS.mjs +54 -0
- package/dist/locales-helpers-qiwh7nxS.mjs.map +1 -0
- package/dist/node/content.d.mts +0 -1
- package/dist/node/content.d.mts.map +1 -1
- package/dist/node/content.d.ts +3 -0
- package/dist/node/content.d.ts.map +1 -0
- package/dist/node/content.js +2 -0
- package/dist/node/content.mjs +2 -4
- package/dist/node/index.d.mts +151 -3
- package/dist/node/index.d.mts.map +1 -1
- package/dist/node/index.d.ts +4 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +3 -0
- package/dist/node/index.mjs +1857 -97
- package/dist/node/index.mjs.map +1 -1
- package/dist/{serialize-props-Dhv_MnkY.mjs → serialize-props-BHoNpzH6.mjs} +2 -3
- package/dist/{serialize-props-Dhv_MnkY.mjs.map → serialize-props-BHoNpzH6.mjs.map} +1 -1
- package/dist/src/cms-handler.d.ts +19 -0
- package/dist/src/cms-handler.d.ts.map +1 -0
- package/dist/src/cms-handler.js +366 -0
- package/dist/src/collections.d.ts +32 -0
- package/dist/src/collections.d.ts.map +1 -0
- package/dist/src/collections.js +50 -0
- package/dist/src/components/HydrationWrapper.d.ts +18 -0
- package/dist/src/components/HydrationWrapper.d.ts.map +1 -0
- package/dist/src/components/HydrationWrapper.js +21 -0
- package/dist/src/components/RenderWithBlocks.d.ts +23 -0
- package/dist/src/components/RenderWithBlocks.d.ts.map +1 -0
- package/dist/src/components/RenderWithBlocks.js +129 -0
- package/dist/src/components/RenderWithHydration.d.ts +17 -0
- package/dist/src/components/RenderWithHydration.d.ts.map +1 -0
- package/dist/src/components/RenderWithHydration.js +36 -0
- package/dist/src/components.d.ts +4 -0
- package/dist/src/components.d.ts.map +1 -0
- package/dist/src/components.js +3 -0
- package/dist/src/discovery/astro-frontmatter.d.ts +18 -0
- package/dist/src/discovery/astro-frontmatter.d.ts.map +1 -0
- package/dist/src/discovery/astro-frontmatter.js +24 -0
- package/dist/src/discovery/extract-props-ts.d.ts +41 -0
- package/dist/src/discovery/extract-props-ts.d.ts.map +1 -0
- package/dist/src/discovery/extract-props-ts.js +231 -0
- package/dist/src/discovery/merge-registry.d.ts +58 -0
- package/dist/src/discovery/merge-registry.d.ts.map +1 -0
- package/dist/src/discovery/merge-registry.js +332 -0
- package/dist/src/discovery/registry-endpoint.d.ts +42 -0
- package/dist/src/discovery/registry-endpoint.d.ts.map +1 -0
- package/dist/src/discovery/registry-endpoint.js +81 -0
- package/dist/src/discovery/scan-components.d.ts +98 -0
- package/dist/src/discovery/scan-components.d.ts.map +1 -0
- package/dist/src/discovery/scan-components.js +399 -0
- package/dist/src/discovery/scan-mdx.d.ts +63 -0
- package/dist/src/discovery/scan-mdx.d.ts.map +1 -0
- package/dist/src/discovery/scan-mdx.js +112 -0
- package/dist/src/discovery/scan-overrides.d.ts +71 -0
- package/dist/src/discovery/scan-overrides.d.ts.map +1 -0
- package/dist/src/discovery/scan-overrides.js +33 -0
- package/dist/src/hydration.d.ts +4 -0
- package/dist/src/hydration.d.ts.map +1 -0
- package/dist/src/hydration.js +4 -0
- package/dist/src/index.d.ts +11 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +25 -0
- package/dist/src/lib/hydration-scanner.d.ts +47 -0
- package/dist/src/lib/hydration-scanner.d.ts.map +1 -0
- package/dist/src/lib/hydration-scanner.js +135 -0
- package/dist/src/lib/hydration-script.d.ts +28 -0
- package/dist/src/lib/hydration-script.d.ts.map +1 -0
- package/dist/src/lib/hydration-script.js +88 -0
- package/dist/src/lib/hydration-utils.d.ts +51 -0
- package/dist/src/lib/hydration-utils.d.ts.map +1 -0
- package/dist/src/lib/hydration-utils.js +83 -0
- package/dist/src/lib/page-api.d.ts +77 -0
- package/dist/src/lib/page-api.d.ts.map +1 -0
- package/dist/src/lib/page-api.js +121 -0
- package/dist/src/lib/route-utils.d.ts +41 -0
- package/dist/src/lib/route-utils.d.ts.map +1 -0
- package/dist/src/lib/route-utils.js +78 -0
- package/dist/src/lib/routing-config.d.ts +32 -0
- package/dist/src/lib/routing-config.d.ts.map +1 -0
- package/dist/src/lib/routing-config.js +93 -0
- package/dist/src/lib/serialize-props.d.ts +6 -0
- package/dist/src/lib/serialize-props.d.ts.map +1 -0
- package/dist/src/lib/serialize-props.js +7 -0
- package/dist/src/lib/virtual-module-generators.d.ts +57 -0
- package/dist/src/lib/virtual-module-generators.d.ts.map +1 -0
- package/dist/src/lib/virtual-module-generators.js +263 -0
- package/dist/src/lib/withHydration.d.ts +51 -0
- package/dist/src/lib/withHydration.d.ts.map +1 -0
- package/dist/src/lib/withHydration.js +49 -0
- package/dist/src/loader.d.ts +14 -0
- package/dist/src/loader.d.ts.map +1 -0
- package/dist/src/loader.js +89 -0
- package/dist/src/locales-helpers.d.ts +61 -0
- package/dist/src/locales-helpers.d.ts.map +1 -0
- package/dist/src/locales-helpers.js +49 -0
- package/dist/src/mime-types.d.ts +3 -0
- package/dist/src/mime-types.d.ts.map +1 -0
- package/dist/src/mime-types.js +19 -0
- package/dist/src/path-validation.d.ts +8 -0
- package/dist/src/path-validation.d.ts.map +1 -0
- package/dist/src/path-validation.js +12 -0
- package/dist/src/plugin-spa.d.ts +164 -0
- package/dist/src/plugin-spa.d.ts.map +1 -0
- package/dist/src/plugin-spa.js +972 -0
- package/dist/src/safe-json-stringify.d.ts +13 -0
- package/dist/src/safe-json-stringify.d.ts.map +1 -0
- package/dist/src/safe-json-stringify.js +6 -0
- package/dist/src/site-styles/content-wrapper-endpoint.d.ts +76 -0
- package/dist/src/site-styles/content-wrapper-endpoint.d.ts.map +1 -0
- package/dist/src/site-styles/content-wrapper-endpoint.js +227 -0
- package/dist/src/site-styles/render-endpoint.d.ts +55 -0
- package/dist/src/site-styles/render-endpoint.d.ts.map +1 -0
- package/dist/src/site-styles/render-endpoint.js +263 -0
- package/dist/src/site-styles/styles-endpoint.d.ts +61 -0
- package/dist/src/site-styles/styles-endpoint.d.ts.map +1 -0
- package/dist/src/site-styles/styles-endpoint.js +158 -0
- package/dist/src/types.d.ts +627 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +1 -0
- package/dist/{types-CVQNmPxF.d.mts → types-CS9neadI.d.mts} +193 -3
- package/dist/types-CS9neadI.d.mts.map +1 -0
- package/dist/virtual-modules.d.ts +155 -0
- package/dist/{withHydration-EzyzBQ-Y.mjs → withHydration-C256ox_6.mjs} +2 -2
- package/dist/{withHydration-EzyzBQ-Y.mjs.map → withHydration-C256ox_6.mjs.map} +1 -1
- package/dist/{withHydration-HIvO9ysY.d.mts → withHydration-DkKpkmzJ.d.mts} +1 -2
- package/dist/withHydration-DkKpkmzJ.d.mts.map +1 -0
- package/package.json +82 -26
- package/dist/collections.mjs.map +0 -1
- package/dist/hydration-scanner-B0NjYkZ_.mjs +0 -109
- package/dist/hydration-scanner-B0NjYkZ_.mjs.map +0 -1
- package/dist/loader-By-AQWHc.mjs +0 -68
- package/dist/loader-By-AQWHc.mjs.map +0 -1
- package/dist/types-CVQNmPxF.d.mts.map +0 -1
- package/dist/withHydration-HIvO9ysY.d.mts.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Data } from "@puckeditor/core";
|
|
2
|
-
|
|
2
|
+
import { DataCollectionEntry, PageReference } from "@conloca/content-api";
|
|
3
3
|
//#region src/types.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Hydration strategy for Puck components in production.
|
|
@@ -298,6 +298,196 @@ interface RouteConfig {
|
|
|
298
298
|
*/
|
|
299
299
|
dataBindings?: DataBindingConfig;
|
|
300
300
|
}
|
|
301
|
+
/**
|
|
302
|
+
* Complete page data for rendering.
|
|
303
|
+
*
|
|
304
|
+
* This is what the page-handler.astro receives after
|
|
305
|
+
* loading content from the matched route.
|
|
306
|
+
*
|
|
307
|
+
* Contains:
|
|
308
|
+
* - Puck editor data for rendering
|
|
309
|
+
* - Page metadata for SEO/layouts
|
|
310
|
+
* - Route information for context
|
|
311
|
+
*/
|
|
312
|
+
interface PageData {
|
|
313
|
+
/**
|
|
314
|
+
* Unique page identifier from the content collection.
|
|
315
|
+
*
|
|
316
|
+
* Typically matches the URL path (e.g., 'about', 'blog/post-1').
|
|
317
|
+
*/
|
|
318
|
+
id: string;
|
|
319
|
+
/**
|
|
320
|
+
* Page title from content metadata.
|
|
321
|
+
*
|
|
322
|
+
* Used for:
|
|
323
|
+
* - <title> tag
|
|
324
|
+
* - Layout heading
|
|
325
|
+
* - Navigation/breadcrumbs
|
|
326
|
+
*
|
|
327
|
+
* May be undefined if page has no title set.
|
|
328
|
+
*/
|
|
329
|
+
title?: string;
|
|
330
|
+
/**
|
|
331
|
+
* Page description for SEO.
|
|
332
|
+
*
|
|
333
|
+
* Used for:
|
|
334
|
+
* - <meta name="description">
|
|
335
|
+
* - Social sharing previews
|
|
336
|
+
*/
|
|
337
|
+
description?: string;
|
|
338
|
+
/**
|
|
339
|
+
* URL pathname for this page.
|
|
340
|
+
*
|
|
341
|
+
* Always starts with '/' and matches the route pattern.
|
|
342
|
+
*
|
|
343
|
+
* @example '/about'
|
|
344
|
+
* @example '/blog/my-first-post'
|
|
345
|
+
*/
|
|
346
|
+
pathname: string;
|
|
347
|
+
/**
|
|
348
|
+
* Puck editor data for rendering.
|
|
349
|
+
*
|
|
350
|
+
* This is the Data object from @puckeditor/core containing:
|
|
351
|
+
* - root: Root component props
|
|
352
|
+
* - content: Array of component instances
|
|
353
|
+
* - zones: Named drop zones with nested content
|
|
354
|
+
*
|
|
355
|
+
* Passed directly to <Render config={} data={puckData} />
|
|
356
|
+
*/
|
|
357
|
+
puckData: Data;
|
|
358
|
+
/**
|
|
359
|
+
* Content collection this page belongs to.
|
|
360
|
+
*
|
|
361
|
+
* @example 'pages', 'posts', 'docs'
|
|
362
|
+
*/
|
|
363
|
+
collection: string;
|
|
364
|
+
/**
|
|
365
|
+
* Route configuration that matched this page.
|
|
366
|
+
*
|
|
367
|
+
* Includes the pattern, layout path, and any meta.
|
|
368
|
+
* Useful for conditional rendering based on route.
|
|
369
|
+
*/
|
|
370
|
+
route: {
|
|
371
|
+
/**
|
|
372
|
+
* Route identifier from the config.
|
|
373
|
+
* @example 'pages', 'blog'
|
|
374
|
+
*/
|
|
375
|
+
name: string;
|
|
376
|
+
/**
|
|
377
|
+
* Original pattern from RouteConfig.
|
|
378
|
+
*/
|
|
379
|
+
pattern: string;
|
|
380
|
+
/**
|
|
381
|
+
* Route-specific metadata if configured.
|
|
382
|
+
*/
|
|
383
|
+
meta?: Record<string, unknown>;
|
|
384
|
+
};
|
|
385
|
+
/**
|
|
386
|
+
* Additional page metadata from content.
|
|
387
|
+
*
|
|
388
|
+
* Custom fields stored in the page's frontmatter/metadata.
|
|
389
|
+
* Schema depends on the site's content configuration.
|
|
390
|
+
*/
|
|
391
|
+
meta?: Record<string, unknown>;
|
|
392
|
+
/**
|
|
393
|
+
* Timestamps for the page content.
|
|
394
|
+
*/
|
|
395
|
+
timestamps?: {
|
|
396
|
+
/**
|
|
397
|
+
* When the page was first created.
|
|
398
|
+
*/
|
|
399
|
+
created?: Date;
|
|
400
|
+
/**
|
|
401
|
+
* When the page was last modified.
|
|
402
|
+
*/
|
|
403
|
+
modified?: Date;
|
|
404
|
+
/**
|
|
405
|
+
* When the page was published (if different from created).
|
|
406
|
+
*/
|
|
407
|
+
published?: Date;
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Props passed to layout components wrapping page content.
|
|
412
|
+
*
|
|
413
|
+
* Layouts receive common props (title, description) that work with
|
|
414
|
+
* most existing layouts. No special Conloca-specific layout needed.
|
|
415
|
+
*
|
|
416
|
+
* @example Astro layout usage
|
|
417
|
+
* ```astro
|
|
418
|
+
* ---
|
|
419
|
+
* interface Props {
|
|
420
|
+
* title: string;
|
|
421
|
+
* description?: string;
|
|
422
|
+
* }
|
|
423
|
+
*
|
|
424
|
+
* const { title, description } = Astro.props;
|
|
425
|
+
* ---
|
|
426
|
+
*
|
|
427
|
+
* <html>
|
|
428
|
+
* <head>
|
|
429
|
+
* <title>{title}</title>
|
|
430
|
+
* {description && <meta name="description" content={description} />}
|
|
431
|
+
* </head>
|
|
432
|
+
* <body>
|
|
433
|
+
* <slot />
|
|
434
|
+
* </body>
|
|
435
|
+
* </html>
|
|
436
|
+
* ```
|
|
437
|
+
*
|
|
438
|
+
* @example React layout usage
|
|
439
|
+
* ```tsx
|
|
440
|
+
* interface LayoutProps {
|
|
441
|
+
* title: string;
|
|
442
|
+
* description?: string;
|
|
443
|
+
* children: React.ReactNode;
|
|
444
|
+
* }
|
|
445
|
+
*
|
|
446
|
+
* export default function Layout({ title, children }: LayoutProps) {
|
|
447
|
+
* return (
|
|
448
|
+
* <div className="layout">
|
|
449
|
+
* <header>
|
|
450
|
+
* <h1>{title}</h1>
|
|
451
|
+
* </header>
|
|
452
|
+
* <main>{children}</main>
|
|
453
|
+
* </div>
|
|
454
|
+
* );
|
|
455
|
+
* }
|
|
456
|
+
* ```
|
|
457
|
+
*/
|
|
458
|
+
interface LayoutProps {
|
|
459
|
+
/**
|
|
460
|
+
* Page title for the document head.
|
|
461
|
+
*/
|
|
462
|
+
title: string;
|
|
463
|
+
/**
|
|
464
|
+
* Page description for SEO meta tag.
|
|
465
|
+
*/
|
|
466
|
+
description?: string;
|
|
467
|
+
/**
|
|
468
|
+
* The rendered Puck content.
|
|
469
|
+
*
|
|
470
|
+
* In Astro layouts, use <slot /> instead of {children}.
|
|
471
|
+
* In React layouts, render {children} in the content area.
|
|
472
|
+
*/
|
|
473
|
+
children?: unknown;
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Resolved routing configuration with all fields required.
|
|
477
|
+
*
|
|
478
|
+
* This is what the page handler receives via the virtual module,
|
|
479
|
+
* with all defaults applied.
|
|
480
|
+
*/
|
|
481
|
+
interface ResolvedRoutingConfig {
|
|
482
|
+
enabled: boolean;
|
|
483
|
+
routes: Record<string, Required<RouteConfig>>;
|
|
484
|
+
fallback: '404' | 'passthrough';
|
|
485
|
+
onConflict: 'warn' | 'error' | 'silent';
|
|
486
|
+
/** Site name for content resolution. */
|
|
487
|
+
siteName: string;
|
|
488
|
+
/** Default locale for content resolution. */
|
|
489
|
+
locale: string;
|
|
490
|
+
}
|
|
301
491
|
/**
|
|
302
492
|
* Configuration for automatic data collection injection into Puck components.
|
|
303
493
|
*
|
|
@@ -429,5 +619,5 @@ interface TemplateConfig {
|
|
|
429
619
|
description?: string;
|
|
430
620
|
}
|
|
431
621
|
//#endregion
|
|
432
|
-
export {
|
|
433
|
-
//# sourceMappingURL=types-
|
|
622
|
+
export { PageReference as a, TemplateConfig as c, PageData as i, HydrationStrategy as n, ResolvedRoutingConfig as o, LayoutProps as r, RoutingConfigInput as s, DataCollectionEntry as t };
|
|
623
|
+
//# sourceMappingURL=types-CS9neadI.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-CS9neadI.d.mts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;KAuBY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA2CK;;;;;;;;;EASf;;;;;;;;;;;;;;;EAgBA,SAAS,eAAe;;;;;;;;;;;;EAaxB;;;;;;;;;;;;EAaA;;;;;;;;;;;;;;;;;;;;EAqBA;;;;;;;;;;;;;;;;;;;;EAqBA;;;;;;;;;;;;;;;KAgBU,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAqC1B;;;;;;;;;;;;;;;EAef;;;;;;;;;;;;;;;;EAiBA;;;;;;;;;;;;;;;;;EAkBA;;;;;;;;;;;;;;;;;;;EAoBA;;;;;;;;;EAUA,OAAO;;;;;;;;;;;;;;;;;EAkBP,eAAe;;;;;;;;;;;;;UAcA;;;;;;EAMf;;;;;;;;;;;EAYA;;;;;;;;EASA;;;;;;;;;EAUA;;;;;;;;;;;EAYA,UAAU;;;;;;EAOV;;;;;;;EAQA;;;;;IAKE;;;;IAKA;;;;IAKA,OAAO;;;;;;;;EAST,OAAO;;;;EAKP;;;;IAIE,UAAU;;;;IAKV,WAAW;;;;IAKX,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAoDC;;;;EAIf;;;;EAKA;;;;;;;EAQA;;;;;;;;UAiBe;EACf;EACA,QAAQ,eAAe,SAAS;EAChC;EACA;;EAEA;;EAEA;;;;;;;;;;;;;;;;;;;;;;;;UA6Be;;;;;;;;;;EAUf;;;;;;;EAQA;;;;;;;;;;;;;;;;;;;;;EAsBA;;;;;;;;;IASE;;;;;;IAOA;;;;;;;;;;IAWA;;;;;;;;;;;;;;;;;;;;;;UA0Ba;;;;;EAKf;;;;;;EAOA;;;;;;EAOA;;;;EAKA"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type declarations for Conloca virtual modules.
|
|
3
|
+
*
|
|
4
|
+
* These modules are generated at build/dev time by the Vite plugin
|
|
5
|
+
* and provide routing configuration, layout components, page API,
|
|
6
|
+
* and Puck config to page handlers.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { LayoutProps, PageData, PageReference, ResolvedRoutingConfig } from '@conloca/astro-cms';
|
|
10
|
+
import type { Config } from '@puckeditor/core';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Virtual module: virtual:conloca-routing-config
|
|
14
|
+
*
|
|
15
|
+
* Provides resolved routing configuration to page handlers.
|
|
16
|
+
* All defaults are applied before this module is generated.
|
|
17
|
+
*/
|
|
18
|
+
declare module 'virtual:conloca-routing-config' {
|
|
19
|
+
const config: ResolvedRoutingConfig;
|
|
20
|
+
export default config;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Virtual module: virtual:conloca-layout
|
|
25
|
+
*
|
|
26
|
+
* Provides the layout component for content pages.
|
|
27
|
+
* Returns undefined if no layout is configured.
|
|
28
|
+
*
|
|
29
|
+
* Currently uses the first route's layout - multi-layout support
|
|
30
|
+
* is planned for future versions.
|
|
31
|
+
*/
|
|
32
|
+
declare module 'virtual:conloca-layout' {
|
|
33
|
+
type LayoutComponent = ((props: LayoutProps) => unknown) | undefined;
|
|
34
|
+
|
|
35
|
+
const Layout: LayoutComponent;
|
|
36
|
+
export default Layout;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Virtual module: virtual:conloca-page-api
|
|
41
|
+
*
|
|
42
|
+
* Provides ContentAPI-backed helpers for the dev-only CMS runtime.
|
|
43
|
+
* Public page routing uses Astro content collections directly.
|
|
44
|
+
*/
|
|
45
|
+
declare module 'virtual:conloca-page-api' {
|
|
46
|
+
/**
|
|
47
|
+
* Content configuration options for ContentAPI initialization.
|
|
48
|
+
* Useful for creating additional ContentAPI instances (e.g., for MDX evaluation).
|
|
49
|
+
*/
|
|
50
|
+
export const contentOptions: {
|
|
51
|
+
/** Path to content directory */
|
|
52
|
+
contentRoot: string;
|
|
53
|
+
/** Path to canvas/puck directory */
|
|
54
|
+
canvasDir: string;
|
|
55
|
+
/** Site name for content resolution */
|
|
56
|
+
siteName: string;
|
|
57
|
+
/** Default locale for content resolution */
|
|
58
|
+
locale: string;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Get all pages for static path generation.
|
|
63
|
+
* @param collection - Optional collection filter (defaults to all collections)
|
|
64
|
+
* @returns Array of page references with id, pathname, title, collection
|
|
65
|
+
*/
|
|
66
|
+
export function getAllPages(collection?: string): Promise<PageReference[]>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Load full page data for rendering.
|
|
70
|
+
* @param pathname - URL pathname (e.g., '/about')
|
|
71
|
+
* @param collection - Optional collection to search in
|
|
72
|
+
* @returns Full page data including puckData for rendering
|
|
73
|
+
* @throws Error with code 'PAGE_NOT_FOUND' if page doesn't exist
|
|
74
|
+
*/
|
|
75
|
+
export function getPage(pathname: string, collection?: string): Promise<PageData>;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Check if a page exists without loading full data.
|
|
79
|
+
* @param pathname - URL pathname
|
|
80
|
+
* @param collection - Optional collection filter
|
|
81
|
+
* @returns true if page exists, false otherwise
|
|
82
|
+
*/
|
|
83
|
+
export function pageExists(pathname: string, collection?: string): Promise<boolean>;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Get all entries from a data collection.
|
|
87
|
+
*
|
|
88
|
+
* Fetches all entries from a data collection and returns them as
|
|
89
|
+
* simplified DataCollectionEntry objects for use in Puck component resolvers.
|
|
90
|
+
*
|
|
91
|
+
* @param collection - Data collection name
|
|
92
|
+
* @param locale - Optional locale override (defaults to configured locale)
|
|
93
|
+
* @returns Array of DataCollectionEntry objects with id, name, data, and meta
|
|
94
|
+
*/
|
|
95
|
+
export function getDataCollection(
|
|
96
|
+
collection: string,
|
|
97
|
+
locale?: string,
|
|
98
|
+
): Promise<import('@conloca/astro-cms').DataCollectionEntry[]>;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Get pages matching a path prefix.
|
|
102
|
+
*
|
|
103
|
+
* Filters all pages by pathname prefix and returns them sorted.
|
|
104
|
+
* Excludes the listing page itself (exact prefix match).
|
|
105
|
+
*
|
|
106
|
+
* @param prefix - Path prefix to match (e.g., '/blog/')
|
|
107
|
+
* @param options - Optional sort and limit settings
|
|
108
|
+
* @returns Array of PageReference objects with meta and timestamps
|
|
109
|
+
*
|
|
110
|
+
* @example Get latest 10 blog posts
|
|
111
|
+
* ```typescript
|
|
112
|
+
* const posts = await getPagesByPrefix('/blog/', {
|
|
113
|
+
* sort: 'date-desc',
|
|
114
|
+
* limit: 10,
|
|
115
|
+
* });
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export function getPagesByPrefix(
|
|
119
|
+
prefix: string,
|
|
120
|
+
options?: {
|
|
121
|
+
sort?: 'date-desc' | 'date-asc' | 'title';
|
|
122
|
+
limit?: number;
|
|
123
|
+
},
|
|
124
|
+
): Promise<PageReference[]>;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Virtual module: virtual:conloca-puck-config
|
|
129
|
+
*
|
|
130
|
+
* Provides Puck configuration for static page rendering.
|
|
131
|
+
*
|
|
132
|
+
* This is separate from the HMR-enabled puck-entry.js used by
|
|
133
|
+
* the CMS SPA. It's a simple re-export without React refresh
|
|
134
|
+
* preamble since it's used for SSG builds.
|
|
135
|
+
*/
|
|
136
|
+
declare module 'virtual:conloca-puck-config' {
|
|
137
|
+
const config: Config;
|
|
138
|
+
export default config;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Virtual module: virtual:conloca-hydration-entry
|
|
143
|
+
*
|
|
144
|
+
* Client-side script that handles progressive hydration of interactive
|
|
145
|
+
* components. Loaded only when a page contains hydratable components.
|
|
146
|
+
*/
|
|
147
|
+
declare module 'virtual:conloca-hydration-entry' {}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Virtual module: virtual:conloca-hydration-registry
|
|
151
|
+
*
|
|
152
|
+
* Maps component names to dynamic import functions for lazy-loading
|
|
153
|
+
* hydratable components on the client.
|
|
154
|
+
*/
|
|
155
|
+
declare module 'virtual:conloca-hydration-registry' {}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withHydration-
|
|
1
|
+
{"version":3,"file":"withHydration-C256ox_6.mjs","names":[],"sources":["../src/lib/withHydration.ts"],"sourcesContent":["import type React from 'react';\n\n/**\n * Metadata attached to components marked for hydration.\n * Used by the build-time scanner and runtime hydration system.\n */\nexport interface HydrationMeta {\n strategy: 'load' | 'visible' | 'idle';\n __isHydratable: true;\n}\n\n/**\n * Hydration strategy for the withHydration wrapper.\n * Does not include 'none' since wrapping implies hydration is desired.\n */\nexport type WithHydrationStrategy = 'load' | 'visible' | 'idle';\n\n/**\n * Marks a component's render function for client-side hydration.\n *\n * This wrapper attaches metadata to the component function, enabling:\n * 1. Build-time discovery via static analysis of source files\n * 2. Runtime hydration strategy determination\n *\n * The wrapper does NOT create a new component or add runtime overhead.\n * It simply attaches a `__hydration` property to the existing function.\n *\n * **Constraint:** Hydratable components must not use `puck.renderDropZone`,\n * `puck.isEditing`, or `puck.metadata` — the `puck` prop is stripped during\n * serialization and not available at hydration time.\n *\n * @param Component - The React component to mark for hydration\n * @param strategy - When to hydrate: 'load', 'visible', or 'idle'\n * @returns The same component with hydration metadata attached\n *\n * @example\n * ```tsx\n * // In a Puck component file (e.g., TestimonialGrid.tsx)\n * import { withHydration } from '@conloca/astro-cms'\n *\n * const TestimonialGridComponent = ({ title, testimonials }) => {\n * const [currentPage, setCurrentPage] = useState(0)\n * // ... interactive logic\n * }\n *\n * export const TestimonialGrid: ComponentConfig<Props> = {\n * fields: { ... },\n * defaultProps: { ... },\n * render: withHydration(TestimonialGridComponent, 'visible'),\n * }\n * ```\n */\nexport function withHydration<T extends (props: any) => React.ReactNode>(\n Component: T,\n strategy: WithHydrationStrategy,\n): T {\n // Environment variable escape hatch for debugging\n if (typeof process !== 'undefined' && process.env?.CONLOCA_DISABLE_HYDRATION === 'true') {\n return Component;\n }\n\n // Attach metadata directly to the function object\n // This avoids creating a wrapper component and keeps bundle size minimal\n const HydratableComponent = Component as T & { __hydration: HydrationMeta };\n HydratableComponent.__hydration = {\n strategy,\n __isHydratable: true,\n };\n\n return HydratableComponent;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,SAAgB,cACd,WACA,UACG;CAEH,IAAI,OAAO,YAAY,eAAe,QAAQ,KAAK,8BAA8B,QAC/E,OAAO;CAKT,MAAM,sBAAsB;CAC5B,oBAAoB,cAAc;EAChC;EACA,gBAAgB;CAClB;CAEA,OAAO;AACT"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
3
2
|
//#region src/lib/withHydration.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Metadata attached to components marked for hydration.
|
|
@@ -52,4 +51,4 @@ type WithHydrationStrategy = 'load' | 'visible' | 'idle';
|
|
|
52
51
|
declare function withHydration<T extends (props: any) => React.ReactNode>(Component: T, strategy: WithHydrationStrategy): T;
|
|
53
52
|
//#endregion
|
|
54
53
|
export { WithHydrationStrategy as n, withHydration as r, HydrationMeta as t };
|
|
55
|
-
//# sourceMappingURL=withHydration-
|
|
54
|
+
//# sourceMappingURL=withHydration-DkKpkmzJ.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withHydration-DkKpkmzJ.d.mts","names":[],"sources":["../src/lib/withHydration.ts"],"mappings":";;;;;;UAMiB;EACf;EACA;;;;;;KAOU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqCI,cAAc,WAAW,eAAe,MAAM,WAC5D,WAAW,GACX,UAAU,wBACT"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@conloca/astro-cms",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/conloca/conloca.git",
|
|
10
|
-
"directory": "astro-cms"
|
|
10
|
+
"directory": "packages/astro-cms"
|
|
11
11
|
},
|
|
12
12
|
"type": "module",
|
|
13
13
|
"main": "./dist/index.mjs",
|
|
@@ -45,12 +45,8 @@
|
|
|
45
45
|
"import": "./dist/components.mjs",
|
|
46
46
|
"default": "./dist/components.mjs"
|
|
47
47
|
},
|
|
48
|
-
"./page-handler": {
|
|
49
|
-
"import": "./dist/internal/page-handler.astro",
|
|
50
|
-
"default": "./dist/internal/page-handler.astro"
|
|
51
|
-
},
|
|
52
48
|
"./virtual-modules": {
|
|
53
|
-
"types": "./
|
|
49
|
+
"types": "./dist/virtual-modules.d.ts"
|
|
54
50
|
},
|
|
55
51
|
"./lib/hydration-script": {
|
|
56
52
|
"types": "./dist/lib/hydration-script.d.mts",
|
|
@@ -64,45 +60,105 @@
|
|
|
64
60
|
}
|
|
65
61
|
},
|
|
66
62
|
"scripts": {
|
|
67
|
-
"
|
|
68
|
-
"test": "tsc-bun-test",
|
|
69
|
-
"test:watch": "bun test --watch"
|
|
63
|
+
"test": "nx run astro-cms:test --outputStyle=stream"
|
|
70
64
|
},
|
|
71
65
|
"files": [
|
|
72
66
|
"dist",
|
|
73
67
|
"!**/*.tsbuildinfo"
|
|
74
68
|
],
|
|
75
69
|
"dependencies": {
|
|
76
|
-
"@conloca/cms-spa": "
|
|
77
|
-
"@conloca/content-api": "
|
|
78
|
-
"@conloca/mdx": "
|
|
79
|
-
"@puckeditor/core": "^0.21.
|
|
70
|
+
"@conloca/cms-spa": "0.1.16",
|
|
71
|
+
"@conloca/content-api": "0.1.16",
|
|
72
|
+
"@conloca/mdx": "0.1.16",
|
|
73
|
+
"@puckeditor/core": "^0.21.2",
|
|
80
74
|
"clsx": "^2.1.1",
|
|
81
75
|
"fast-glob": "^3.3.2",
|
|
76
|
+
"mdast-util-from-markdown": "^2.0.0",
|
|
77
|
+
"mdast-util-mdx": "^3.0.0",
|
|
78
|
+
"micromark-extension-mdxjs": "^3.0.0",
|
|
79
|
+
"ts-morph": "^28.0.0",
|
|
82
80
|
"tslib": "^2.8.1"
|
|
83
81
|
},
|
|
84
82
|
"peerDependencies": {
|
|
85
|
-
"astro": "^5.0.0 || ^6.0.0",
|
|
86
|
-
"vite": "^6.0.0 || ^7.0.0",
|
|
87
83
|
"@vitejs/plugin-react": "^4.0.0",
|
|
88
|
-
"
|
|
89
|
-
"react
|
|
90
|
-
"
|
|
84
|
+
"astro": "^7.1.3",
|
|
85
|
+
"react": "^19.2.5",
|
|
86
|
+
"react-dom": "^19.2.5",
|
|
87
|
+
"vite": "^6.0.0 || ^7.0.0 || ^8.0.0",
|
|
88
|
+
"zod": "^4.4.1"
|
|
91
89
|
},
|
|
92
90
|
"devDependencies": {
|
|
93
91
|
"@happy-dom/global-registrator": "20.6.1",
|
|
94
92
|
"@testing-library/jest-dom": "^6.9.1",
|
|
95
|
-
"@vitejs/plugin-react": "^
|
|
96
|
-
"astro": "
|
|
97
|
-
"vite": "^
|
|
93
|
+
"@vitejs/plugin-react": "^5.2.0",
|
|
94
|
+
"astro": "^7.1.3",
|
|
95
|
+
"vite": "^8.1.5",
|
|
96
|
+
"vitest": "^4.1.7"
|
|
98
97
|
},
|
|
99
98
|
"nx": {
|
|
100
99
|
"targets": {
|
|
101
|
-
"
|
|
100
|
+
"clean": {},
|
|
101
|
+
"tsdown-js": {
|
|
102
|
+
"executor": "nx:run-commands",
|
|
103
|
+
"cache": true,
|
|
104
|
+
"dependsOn": [
|
|
105
|
+
"^build"
|
|
106
|
+
],
|
|
107
|
+
"inputs": [
|
|
108
|
+
"{projectRoot}/src/**/*",
|
|
109
|
+
"{projectRoot}/node/**/*",
|
|
110
|
+
"{projectRoot}/tsdown.config.ts",
|
|
111
|
+
"{projectRoot}/tsconfig.lib.json",
|
|
112
|
+
"{projectRoot}/package.json"
|
|
113
|
+
],
|
|
114
|
+
"outputs": [
|
|
115
|
+
"{projectRoot}/dist/**/*.mjs",
|
|
116
|
+
"{projectRoot}/dist/**/*.js",
|
|
117
|
+
"{projectRoot}/dist/**/*.d.mts"
|
|
118
|
+
],
|
|
119
|
+
"options": {
|
|
120
|
+
"command": "tsdown",
|
|
121
|
+
"cwd": "{projectRoot}"
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
"bun-web": {
|
|
125
|
+
"executor": "nx:run-commands",
|
|
126
|
+
"cache": true,
|
|
127
|
+
"inputs": [
|
|
128
|
+
"{projectRoot}/src/handlers/page-handler.astro",
|
|
129
|
+
"{projectRoot}/src/internal/acorn-default.mjs",
|
|
130
|
+
"{projectRoot}/src/virtual-modules.d.ts",
|
|
131
|
+
"{projectRoot}/build.ts"
|
|
132
|
+
],
|
|
133
|
+
"outputs": [
|
|
134
|
+
"{projectRoot}/dist/internal/page-handler.astro",
|
|
135
|
+
"{projectRoot}/dist/internal/acorn-default.mjs",
|
|
136
|
+
"{projectRoot}/dist/virtual-modules.d.ts"
|
|
137
|
+
],
|
|
138
|
+
"options": {
|
|
139
|
+
"command": "bun run build.ts",
|
|
140
|
+
"cwd": "{projectRoot}"
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
"lint": {},
|
|
144
|
+
"test": {
|
|
145
|
+
"executor": "@smoothbricks/nx-plugin:bounded-exec",
|
|
102
146
|
"dependsOn": [
|
|
147
|
+
"typecheck-tests",
|
|
103
148
|
"^build"
|
|
104
|
-
]
|
|
149
|
+
],
|
|
150
|
+
"options": {
|
|
151
|
+
"command": "bun --conditions=production test",
|
|
152
|
+
"cwd": "{projectRoot}",
|
|
153
|
+
"timeoutMs": 120000,
|
|
154
|
+
"killAfterMs": 1e4
|
|
155
|
+
}
|
|
105
156
|
}
|
|
106
|
-
}
|
|
107
|
-
|
|
157
|
+
},
|
|
158
|
+
"tags": [
|
|
159
|
+
"npm:public"
|
|
160
|
+
],
|
|
161
|
+
"name": "astro-cms"
|
|
162
|
+
},
|
|
163
|
+
"license": "FSL-1.1-ALv2"
|
|
108
164
|
}
|
package/dist/collections.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collections.mjs","names":[],"sources":["../src/collections.ts"],"sourcesContent":["import { defineCollection } from 'astro:content';\nimport { createContentAPI } from '@conloca/content-api/reader';\nimport { blockMetaSchema, dataMetaSchema, pageMetaSchema } from '@conloca/content-api/schemas';\nimport { conlocaLoader } from './loader';\n\nexport const ALL_BLOCKS_COLLECTION = '__conloca_blocks';\n\n/**\n * Options for createConlocaCollections().\n */\nexport interface CreateConlocaCollectionsOptions {\n /** Path to content root directory. @default './content' */\n contentRoot?: string;\n /** Site name for multi-site setups. @default 'default' */\n site?: string;\n}\n\n/**\n * Return type of createConlocaCollections().\n */\nexport interface ConlocaCollectionsResult {\n /** Astro Content Collections definitions - export this as `collections` */\n collections: Record<string, ReturnType<typeof defineCollection>>;\n}\n\n/**\n * Creates Astro Content Collections by discovering from indexed content.\n * Uses content-api to find collections that have content.\n *\n * @example\n * ```typescript\n * // src/content.config.ts\n * import { createConlocaCollections } from '@conloca/astro-cms/node/content';\n *\n * export const { collections } = await createConlocaCollections();\n * ```\n */\nexport async function createConlocaCollections(\n options: CreateConlocaCollectionsOptions = {},\n): Promise<ConlocaCollectionsResult> {\n const { contentRoot = './content', site = 'default' } = options;\n\n const api = await createContentAPI({ contentRoot });\n const collections: Record<string, ReturnType<typeof defineCollection>> = {};\n\n collections[ALL_BLOCKS_COLLECTION] = defineCollection({\n loader: conlocaLoader({ contentRoot, site, kind: 'block' }),\n schema: blockMetaSchema.passthrough() as never,\n });\n\n // Add block collections\n for (const name of api.blocks.collections) {\n collections[name] = defineCollection({\n loader: conlocaLoader({ collection: name, contentRoot, site, kind: 'block' }),\n // Cast needed: Astro uses Zod v3 BaseSchema types, our schemas are Zod v4\n schema: blockMetaSchema.passthrough() as never,\n });\n }\n\n // Add data collections\n for (const name of api.data.collections) {\n collections[name] = defineCollection({\n loader: conlocaLoader({ collection: name, contentRoot, site, kind: 'data' }),\n schema: dataMetaSchema.passthrough() as never,\n });\n }\n\n // Add page collections for this site\n const siteCollections = api.getSite(site)?.collections ?? new Set<string>();\n for (const name of siteCollections) {\n collections[name] = defineCollection({\n loader: conlocaLoader({ collection: name, contentRoot, site, kind: 'page' }),\n schema: pageMetaSchema.passthrough() as never,\n });\n }\n\n return { collections };\n}\n"],"mappings":";;;;;;AAKA,MAAa,wBAAwB;;;;;;;;;;;;;AAgCrC,eAAsB,yBACpB,UAA2C,EAAE,EACV;CACnC,MAAM,EAAE,cAAc,aAAa,OAAO,cAAc;CAExD,MAAM,MAAM,MAAM,iBAAiB,EAAE,aAAa,CAAC;CACnD,MAAM,cAAmE,EAAE;AAE3E,aAAY,yBAAyB,iBAAiB;EACpD,QAAQ,cAAc;GAAE;GAAa;GAAM,MAAM;GAAS,CAAC;EAC3D,QAAQ,gBAAgB,aAAa;EACtC,CAAC;AAGF,MAAK,MAAM,QAAQ,IAAI,OAAO,YAC5B,aAAY,QAAQ,iBAAiB;EACnC,QAAQ,cAAc;GAAE,YAAY;GAAM;GAAa;GAAM,MAAM;GAAS,CAAC;EAE7E,QAAQ,gBAAgB,aAAa;EACtC,CAAC;AAIJ,MAAK,MAAM,QAAQ,IAAI,KAAK,YAC1B,aAAY,QAAQ,iBAAiB;EACnC,QAAQ,cAAc;GAAE,YAAY;GAAM;GAAa;GAAM,MAAM;GAAQ,CAAC;EAC5E,QAAQ,eAAe,aAAa;EACrC,CAAC;CAIJ,MAAM,kBAAkB,IAAI,QAAQ,KAAK,EAAE,+BAAe,IAAI,KAAa;AAC3E,MAAK,MAAM,QAAQ,gBACjB,aAAY,QAAQ,iBAAiB;EACnC,QAAQ,cAAc;GAAE,YAAY;GAAM;GAAa;GAAM,MAAM;GAAQ,CAAC;EAC5E,QAAQ,eAAe,aAAa;EACrC,CAAC;AAGJ,QAAO,EAAE,aAAa"}
|