@407dev/cms-astro 0.1.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 +69 -0
- package/dist/chunk-2TKIQIOE.js +118 -0
- package/dist/chunk-2TKIQIOE.js.map +1 -0
- package/dist/chunk-53OQ5RXJ.js +912 -0
- package/dist/chunk-53OQ5RXJ.js.map +1 -0
- package/dist/chunk-56OMNQLH.js +1013 -0
- package/dist/chunk-56OMNQLH.js.map +1 -0
- package/dist/chunk-5AOOMQ7K.js +1031 -0
- package/dist/chunk-5AOOMQ7K.js.map +1 -0
- package/dist/chunk-5XRUCFDC.js +743 -0
- package/dist/chunk-5XRUCFDC.js.map +1 -0
- package/dist/chunk-62ZHCOLZ.js +25 -0
- package/dist/chunk-62ZHCOLZ.js.map +1 -0
- package/dist/chunk-6AZLRSYA.js +126 -0
- package/dist/chunk-6AZLRSYA.js.map +1 -0
- package/dist/chunk-6L3ZTCFB.js +14 -0
- package/dist/chunk-6L3ZTCFB.js.map +1 -0
- package/dist/chunk-6O7ZNNDT.js +697 -0
- package/dist/chunk-6O7ZNNDT.js.map +1 -0
- package/dist/chunk-6PQIXTMK.js +697 -0
- package/dist/chunk-6PQIXTMK.js.map +1 -0
- package/dist/chunk-7AW6M7QW.js +1013 -0
- package/dist/chunk-7AW6M7QW.js.map +1 -0
- package/dist/chunk-7E3XJLKX.js +73 -0
- package/dist/chunk-7E3XJLKX.js.map +1 -0
- package/dist/chunk-7LM54OTA.js +1031 -0
- package/dist/chunk-7LM54OTA.js.map +1 -0
- package/dist/chunk-7LMUFCWX.js +126 -0
- package/dist/chunk-7LMUFCWX.js.map +1 -0
- package/dist/chunk-A3OGL4OX.js +706 -0
- package/dist/chunk-A3OGL4OX.js.map +1 -0
- package/dist/chunk-AO4UAWOV.js +1030 -0
- package/dist/chunk-AO4UAWOV.js.map +1 -0
- package/dist/chunk-B4YYLS7Y.js +14 -0
- package/dist/chunk-B4YYLS7Y.js.map +1 -0
- package/dist/chunk-BDFVGXM2.js +697 -0
- package/dist/chunk-BDFVGXM2.js.map +1 -0
- package/dist/chunk-CXM7NZVX.js +1031 -0
- package/dist/chunk-CXM7NZVX.js.map +1 -0
- package/dist/chunk-DMLOBKYE.js +96 -0
- package/dist/chunk-DMLOBKYE.js.map +1 -0
- package/dist/chunk-DXJSYGS6.js +743 -0
- package/dist/chunk-DXJSYGS6.js.map +1 -0
- package/dist/chunk-EFUSAQZM.js +72 -0
- package/dist/chunk-EFUSAQZM.js.map +1 -0
- package/dist/chunk-F7KDGPBN.js +1013 -0
- package/dist/chunk-F7KDGPBN.js.map +1 -0
- package/dist/chunk-FBSQT45X.js +126 -0
- package/dist/chunk-FBSQT45X.js.map +1 -0
- package/dist/chunk-FEPDOMVH.js +697 -0
- package/dist/chunk-FEPDOMVH.js.map +1 -0
- package/dist/chunk-FQDOL2QW.js +25 -0
- package/dist/chunk-FQDOL2QW.js.map +1 -0
- package/dist/chunk-GB3LGQJM.js +109 -0
- package/dist/chunk-GB3LGQJM.js.map +1 -0
- package/dist/chunk-HCNP6R3P.js +736 -0
- package/dist/chunk-HCNP6R3P.js.map +1 -0
- package/dist/chunk-J6WEJDRI.js +743 -0
- package/dist/chunk-J6WEJDRI.js.map +1 -0
- package/dist/chunk-JHEAPNJ2.js +117 -0
- package/dist/chunk-JHEAPNJ2.js.map +1 -0
- package/dist/chunk-JOJDJ6GW.js +25 -0
- package/dist/chunk-JOJDJ6GW.js.map +1 -0
- package/dist/chunk-KTDV6WYB.js +202 -0
- package/dist/chunk-KTDV6WYB.js.map +1 -0
- package/dist/chunk-KZWJBKPC.js +734 -0
- package/dist/chunk-KZWJBKPC.js.map +1 -0
- package/dist/chunk-LEAQBGL6.js +109 -0
- package/dist/chunk-LEAQBGL6.js.map +1 -0
- package/dist/chunk-LGZJL2Q7.js +697 -0
- package/dist/chunk-LGZJL2Q7.js.map +1 -0
- package/dist/chunk-LQPBU46R.js +109 -0
- package/dist/chunk-LQPBU46R.js.map +1 -0
- package/dist/chunk-M55NNUTY.js +1013 -0
- package/dist/chunk-M55NNUTY.js.map +1 -0
- package/dist/chunk-M6NCYCC3.js +1013 -0
- package/dist/chunk-M6NCYCC3.js.map +1 -0
- package/dist/chunk-MGN7OZAU.js +109 -0
- package/dist/chunk-MGN7OZAU.js.map +1 -0
- package/dist/chunk-MGYZOX4K.js +1013 -0
- package/dist/chunk-MGYZOX4K.js.map +1 -0
- package/dist/chunk-MY4IEKJS.js +1031 -0
- package/dist/chunk-MY4IEKJS.js.map +1 -0
- package/dist/chunk-NCQRGAB4.js +705 -0
- package/dist/chunk-NCQRGAB4.js.map +1 -0
- package/dist/chunk-NI4NHXI4.js +697 -0
- package/dist/chunk-NI4NHXI4.js.map +1 -0
- package/dist/chunk-NPI5N7AU.js +14 -0
- package/dist/chunk-NPI5N7AU.js.map +1 -0
- package/dist/chunk-QN4CPMJF.js +126 -0
- package/dist/chunk-QN4CPMJF.js.map +1 -0
- package/dist/chunk-QYUVAKMC.js +1013 -0
- package/dist/chunk-QYUVAKMC.js.map +1 -0
- package/dist/chunk-RAAT6PDT.js +25 -0
- package/dist/chunk-RAAT6PDT.js.map +1 -0
- package/dist/chunk-RDPO5VPS.js +1013 -0
- package/dist/chunk-RDPO5VPS.js.map +1 -0
- package/dist/chunk-RQHIW2PF.js +25 -0
- package/dist/chunk-RQHIW2PF.js.map +1 -0
- package/dist/chunk-RREVHA52.js +722 -0
- package/dist/chunk-RREVHA52.js.map +1 -0
- package/dist/chunk-S7PT4PZN.js +25 -0
- package/dist/chunk-S7PT4PZN.js.map +1 -0
- package/dist/chunk-SUXV5M32.js +109 -0
- package/dist/chunk-SUXV5M32.js.map +1 -0
- package/dist/chunk-SZEORUY6.js +696 -0
- package/dist/chunk-SZEORUY6.js.map +1 -0
- package/dist/chunk-T7NGGWGY.js +25 -0
- package/dist/chunk-T7NGGWGY.js.map +1 -0
- package/dist/chunk-UEVWP5VE.js +696 -0
- package/dist/chunk-UEVWP5VE.js.map +1 -0
- package/dist/chunk-UJNKNP7U.js +748 -0
- package/dist/chunk-UJNKNP7U.js.map +1 -0
- package/dist/chunk-V4XVFWFI.js +1013 -0
- package/dist/chunk-V4XVFWFI.js.map +1 -0
- package/dist/chunk-VJU2CIKZ.js +729 -0
- package/dist/chunk-VJU2CIKZ.js.map +1 -0
- package/dist/chunk-VRQUP5L3.js +202 -0
- package/dist/chunk-VRQUP5L3.js.map +1 -0
- package/dist/chunk-WBJ5E7CL.js +742 -0
- package/dist/chunk-WBJ5E7CL.js.map +1 -0
- package/dist/chunk-XJPVYMZM.js +24 -0
- package/dist/chunk-XJPVYMZM.js.map +1 -0
- package/dist/chunk-Y3Q65C7R.js +14 -0
- package/dist/chunk-Y3Q65C7R.js.map +1 -0
- package/dist/chunk-YHEGFPTR.js +1030 -0
- package/dist/chunk-YHEGFPTR.js.map +1 -0
- package/dist/chunk-ZDLBN46C.js +697 -0
- package/dist/chunk-ZDLBN46C.js.map +1 -0
- package/dist/dev/index.d.ts +122 -0
- package/dist/dev/index.js +662 -0
- package/dist/dev/index.js.map +1 -0
- package/dist/fields/collections.d.ts +18 -0
- package/dist/fields/collections.js +37 -0
- package/dist/fields/collections.js.map +1 -0
- package/dist/index.d.ts +235 -0
- package/dist/index.js +956 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware/index.d.ts +8 -0
- package/dist/middleware/index.js +13 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/preview-BEkLMD6N.d.ts +23 -0
- package/dist/preview-D9yewK8x.d.ts +24 -0
- package/dist/preview-DJEA4fj7.d.ts +23 -0
- package/dist/preview-DeD1Jn7U.d.ts +23 -0
- package/dist/toolbar/app.d.ts +28 -0
- package/dist/toolbar/app.js +1176 -0
- package/dist/toolbar/app.js.map +1 -0
- package/dist/types-15jfCQKb.d.ts +141 -0
- package/dist/types-BREdL9Gx.d.ts +140 -0
- package/dist/types-C6sUZNa2.d.ts +104 -0
- package/dist/types-CEYS5Fzc.d.ts +112 -0
- package/dist/types-DpeHpobR.d.ts +104 -0
- package/dist/types-NaKJe6Pg.d.ts +140 -0
- package/package.json +90 -0
- package/src/CmsHead.astro +25 -0
- package/src/CmsImage.astro +62 -0
- package/src/CmsVideo.astro +185 -0
- package/src/RichText.astro +32 -0
- package/src/client.test.ts +227 -0
- package/src/client.ts +164 -0
- package/src/dev/config.test.ts +258 -0
- package/src/dev/config.ts +319 -0
- package/src/dev/index.ts +5 -0
- package/src/dev/preview-token.ts +39 -0
- package/src/dev/routes.test.ts +354 -0
- package/src/dev/routes.ts +245 -0
- package/src/dev/token.test.ts +280 -0
- package/src/dev/token.ts +201 -0
- package/src/dev/verifier.test.ts +63 -0
- package/src/dev/verifier.ts +161 -0
- package/src/fields/attrs.ts +24 -0
- package/src/fields/collection.ts +72 -0
- package/src/fields/collections.ts +35 -0
- package/src/fields/entryScope.test.ts +62 -0
- package/src/fields/entryScope.ts +240 -0
- package/src/fields/group.ts +51 -0
- package/src/fields/helpers.test.ts +51 -0
- package/src/fields/helpers.ts +214 -0
- package/src/fields/index.ts +46 -0
- package/src/fields/scope.ts +21 -0
- package/src/fields/types.ts +119 -0
- package/src/head.test.ts +74 -0
- package/src/head.ts +123 -0
- package/src/image.test.ts +42 -0
- package/src/image.ts +64 -0
- package/src/index.test.ts +76 -0
- package/src/index.ts +13 -0
- package/src/integration.ts +218 -0
- package/src/jwt.ts +131 -0
- package/src/middleware/index.ts +4 -0
- package/src/middleware/preview.test.ts +184 -0
- package/src/middleware/preview.ts +206 -0
- package/src/preview/bridge-script.test.ts +683 -0
- package/src/preview/bridge-script.ts +763 -0
- package/src/preview/origins.ts +29 -0
- package/src/preview.ts +49 -0
- package/src/richtext/RichTextNode.astro +130 -0
- package/src/richtext/render.ts +248 -0
- package/src/richtext.test.ts +139 -0
- package/src/runtime/bundle.ts +28 -0
- package/src/runtime/store.ts +130 -0
- package/src/siteFiles.test.ts +93 -0
- package/src/siteFiles.ts +111 -0
- package/src/toolbar/app.test.ts +191 -0
- package/src/toolbar/app.ts +1091 -0
- package/src/toolbar/icon.ts +5 -0
- package/src/toolbar/widgets.test.ts +153 -0
- package/src/toolbar/widgets.ts +365 -0
- package/src/types.test.ts +154 -0
- package/src/types.ts +163 -0
- package/src/version.ts +3 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { z, CmsAsset } from '@407dev/blocks';
|
|
2
|
+
|
|
3
|
+
interface FieldReadOptions<T = unknown> {
|
|
4
|
+
defaultValue?: T;
|
|
5
|
+
}
|
|
6
|
+
interface FieldComponentProps<T = unknown> {
|
|
7
|
+
k?: string;
|
|
8
|
+
key?: string;
|
|
9
|
+
defaultValue?: T;
|
|
10
|
+
as?: string;
|
|
11
|
+
tag?: string;
|
|
12
|
+
class?: string;
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
}
|
|
15
|
+
interface DualCallableHelper<TValue = unknown, TDefault = TValue> {
|
|
16
|
+
/** Synchronous read call: f.text('home.hero.heading', { defaultValue: '...' }) or group.field() */
|
|
17
|
+
(key?: string, options?: FieldReadOptions<TDefault>): TValue;
|
|
18
|
+
(options?: FieldReadOptions<TDefault>): TValue;
|
|
19
|
+
/** JSX / Astro template component call: <f.text k="home.hero.heading" /> */
|
|
20
|
+
(props?: FieldComponentProps<TDefault>): unknown;
|
|
21
|
+
/** Astro component factory call: ($$result, $$props, $$slots) */
|
|
22
|
+
(result: unknown, props: FieldComponentProps<TDefault>, slots?: unknown): unknown;
|
|
23
|
+
isAstroComponentFactory: true;
|
|
24
|
+
typeId: string;
|
|
25
|
+
publicName: string;
|
|
26
|
+
prefix?: string;
|
|
27
|
+
defaultKey?: string;
|
|
28
|
+
}
|
|
29
|
+
interface FieldHelpersMap {
|
|
30
|
+
text: DualCallableHelper<string>;
|
|
31
|
+
number: DualCallableHelper<number>;
|
|
32
|
+
toggle: DualCallableHelper<boolean>;
|
|
33
|
+
select: DualCallableHelper<string>;
|
|
34
|
+
img: DualCallableHelper<CmsAsset | string>;
|
|
35
|
+
image: DualCallableHelper<CmsAsset | string>;
|
|
36
|
+
vid: DualCallableHelper<CmsAsset | string>;
|
|
37
|
+
video: DualCallableHelper<CmsAsset | string>;
|
|
38
|
+
richText: DualCallableHelper<unknown>;
|
|
39
|
+
richtext: DualCallableHelper<unknown>;
|
|
40
|
+
[key: string]: any;
|
|
41
|
+
}
|
|
42
|
+
type FieldScope = FieldHelpersMap & {
|
|
43
|
+
(key: string): string;
|
|
44
|
+
key(key: string): string;
|
|
45
|
+
scope(subPrefix: string): FieldScope;
|
|
46
|
+
readonly prefix: string;
|
|
47
|
+
};
|
|
48
|
+
interface GroupAccessor<TShape = Record<string, unknown>> {
|
|
49
|
+
attrs(): {
|
|
50
|
+
'data-cms-group': string;
|
|
51
|
+
};
|
|
52
|
+
key(key: string): string;
|
|
53
|
+
(key: string): string;
|
|
54
|
+
readonly groupName: string;
|
|
55
|
+
readonly prefix: string;
|
|
56
|
+
}
|
|
57
|
+
type BoundGroupAccessor<TShape> = GroupAccessor<TShape> & {
|
|
58
|
+
[K in keyof TShape]: TShape[K] extends DualCallableHelper<infer TVal, infer TDef> ? DualCallableHelper<TVal, TDef> : DualCallableHelper<unknown>;
|
|
59
|
+
};
|
|
60
|
+
interface GroupDefinition<TShape = Record<string, unknown>> {
|
|
61
|
+
(scopeKey: string): BoundGroupAccessor<TShape>;
|
|
62
|
+
readonly groupName: string;
|
|
63
|
+
readonly shape: TShape;
|
|
64
|
+
}
|
|
65
|
+
interface DefineCollectionOptions<TSchema extends z.ZodTypeAny> {
|
|
66
|
+
key: string;
|
|
67
|
+
schema: TSchema;
|
|
68
|
+
route?: string;
|
|
69
|
+
presentation?: 'visual' | 'form';
|
|
70
|
+
titleField?: string;
|
|
71
|
+
listColumns?: string[];
|
|
72
|
+
bodyField?: string;
|
|
73
|
+
orderable?: boolean;
|
|
74
|
+
seed?: Array<{
|
|
75
|
+
slug: string;
|
|
76
|
+
content: z.input<TSchema>;
|
|
77
|
+
}>;
|
|
78
|
+
}
|
|
79
|
+
interface CollectionHandle<TSchema extends z.ZodTypeAny = z.ZodTypeAny> {
|
|
80
|
+
readonly key: string;
|
|
81
|
+
readonly schema: TSchema;
|
|
82
|
+
readonly route?: string;
|
|
83
|
+
readonly presentation?: 'visual' | 'form';
|
|
84
|
+
readonly titleField?: string;
|
|
85
|
+
readonly listColumns?: string[];
|
|
86
|
+
readonly bodyField?: string;
|
|
87
|
+
readonly orderable?: boolean;
|
|
88
|
+
readonly jsonSchema: Record<string, unknown>;
|
|
89
|
+
readonly schemaVersion: number;
|
|
90
|
+
readonly seed?: Array<{
|
|
91
|
+
slug: string;
|
|
92
|
+
content: z.input<TSchema>;
|
|
93
|
+
}>;
|
|
94
|
+
}
|
|
95
|
+
interface CollectionEntry<TContent = Record<string, unknown>> {
|
|
96
|
+
slug: string;
|
|
97
|
+
content: TContent;
|
|
98
|
+
status: 'draft' | 'published' | 'scheduled';
|
|
99
|
+
published_at?: string | null;
|
|
100
|
+
position?: string | null;
|
|
101
|
+
}
|
|
102
|
+
type InferEntryContent<T> = T extends CollectionHandle<infer TSchema> ? z.infer<TSchema> : Record<string, unknown>;
|
|
103
|
+
interface CollectionStaticPath<TContent = Record<string, unknown>> {
|
|
104
|
+
params: {
|
|
105
|
+
slug: string;
|
|
106
|
+
};
|
|
107
|
+
props: {
|
|
108
|
+
entry: CollectionEntry<TContent>;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export type { BoundGroupAccessor as B, CollectionHandle as C, DefineCollectionOptions as D, FieldScope as F, GroupDefinition as G, InferEntryContent as I, CollectionEntry as a, CollectionStaticPath as b, DualCallableHelper as c, FieldHelpersMap as d, FieldComponentProps as e, FieldReadOptions as f, GroupAccessor as g };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { z, CmsAsset } from '@407dev/blocks';
|
|
2
|
+
|
|
3
|
+
interface FieldReadOptions<T = unknown> {
|
|
4
|
+
defaultValue?: T;
|
|
5
|
+
}
|
|
6
|
+
interface FieldComponentProps<T = unknown> {
|
|
7
|
+
k?: string;
|
|
8
|
+
key?: string;
|
|
9
|
+
defaultValue?: T;
|
|
10
|
+
as?: string;
|
|
11
|
+
tag?: string;
|
|
12
|
+
class?: string;
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
}
|
|
15
|
+
interface DualCallableHelper<TValue = unknown, TDefault = TValue> {
|
|
16
|
+
/** Synchronous read call: f.text('home.hero.heading', { defaultValue: '...' }) or group.field() */
|
|
17
|
+
(key?: string, options?: FieldReadOptions<TDefault>): TValue;
|
|
18
|
+
(options?: FieldReadOptions<TDefault>): TValue;
|
|
19
|
+
/** JSX / Astro template component call: <f.text k="home.hero.heading" /> */
|
|
20
|
+
(props?: FieldComponentProps<TDefault>): unknown;
|
|
21
|
+
/** Astro component factory call: ($$result, $$props, $$slots) */
|
|
22
|
+
(result: unknown, props: FieldComponentProps<TDefault>, slots?: unknown): unknown;
|
|
23
|
+
isAstroComponentFactory: true;
|
|
24
|
+
typeId: string;
|
|
25
|
+
publicName: string;
|
|
26
|
+
prefix?: string;
|
|
27
|
+
defaultKey?: string;
|
|
28
|
+
}
|
|
29
|
+
interface FieldHelpersMap {
|
|
30
|
+
text: DualCallableHelper<string>;
|
|
31
|
+
number: DualCallableHelper<number>;
|
|
32
|
+
toggle: DualCallableHelper<boolean>;
|
|
33
|
+
select: DualCallableHelper<string>;
|
|
34
|
+
img: DualCallableHelper<CmsAsset | string>;
|
|
35
|
+
image: DualCallableHelper<CmsAsset | string>;
|
|
36
|
+
vid: DualCallableHelper<CmsAsset | string>;
|
|
37
|
+
video: DualCallableHelper<CmsAsset | string>;
|
|
38
|
+
richText: DualCallableHelper<unknown>;
|
|
39
|
+
richtext: DualCallableHelper<unknown>;
|
|
40
|
+
[key: string]: any;
|
|
41
|
+
}
|
|
42
|
+
type FieldScope = FieldHelpersMap & {
|
|
43
|
+
(key: string): string;
|
|
44
|
+
key(key: string): string;
|
|
45
|
+
scope(subPrefix: string): FieldScope;
|
|
46
|
+
readonly prefix: string;
|
|
47
|
+
};
|
|
48
|
+
interface GroupAccessor<TShape = Record<string, unknown>> {
|
|
49
|
+
attrs(): {
|
|
50
|
+
'data-cms-group': string;
|
|
51
|
+
};
|
|
52
|
+
key(key: string): string;
|
|
53
|
+
(key: string): string;
|
|
54
|
+
readonly groupName: string;
|
|
55
|
+
readonly prefix: string;
|
|
56
|
+
}
|
|
57
|
+
type BoundGroupAccessor<TShape> = GroupAccessor<TShape> & {
|
|
58
|
+
[K in keyof TShape]: TShape[K] extends DualCallableHelper<infer TVal, infer TDef> ? DualCallableHelper<TVal, TDef> : DualCallableHelper<unknown>;
|
|
59
|
+
};
|
|
60
|
+
interface GroupDefinition<TShape = Record<string, unknown>> {
|
|
61
|
+
(scopeKey: string): BoundGroupAccessor<TShape>;
|
|
62
|
+
readonly groupName: string;
|
|
63
|
+
readonly shape: TShape;
|
|
64
|
+
}
|
|
65
|
+
interface DefineCollectionOptions<TSchema extends z.ZodTypeAny> {
|
|
66
|
+
key: string;
|
|
67
|
+
schema: TSchema;
|
|
68
|
+
route?: string;
|
|
69
|
+
presentation?: 'visual' | 'form';
|
|
70
|
+
titleField?: string;
|
|
71
|
+
listColumns?: string[];
|
|
72
|
+
bodyField?: string;
|
|
73
|
+
orderable?: boolean;
|
|
74
|
+
}
|
|
75
|
+
interface CollectionHandle<TSchema extends z.ZodTypeAny = z.ZodTypeAny> {
|
|
76
|
+
readonly key: string;
|
|
77
|
+
readonly schema: TSchema;
|
|
78
|
+
readonly route?: string;
|
|
79
|
+
readonly presentation?: 'visual' | 'form';
|
|
80
|
+
readonly titleField?: string;
|
|
81
|
+
readonly listColumns?: string[];
|
|
82
|
+
readonly bodyField?: string;
|
|
83
|
+
readonly orderable?: boolean;
|
|
84
|
+
readonly jsonSchema: Record<string, unknown>;
|
|
85
|
+
readonly schemaVersion: number;
|
|
86
|
+
}
|
|
87
|
+
interface CollectionEntry<TContent = Record<string, unknown>> {
|
|
88
|
+
slug: string;
|
|
89
|
+
content: TContent;
|
|
90
|
+
status: 'draft' | 'published' | 'scheduled';
|
|
91
|
+
published_at?: string | null;
|
|
92
|
+
position?: string | null;
|
|
93
|
+
}
|
|
94
|
+
type InferEntryContent<T> = T extends CollectionHandle<infer TSchema> ? z.infer<TSchema> : Record<string, unknown>;
|
|
95
|
+
interface CollectionStaticPath<TContent = Record<string, unknown>> {
|
|
96
|
+
params: {
|
|
97
|
+
slug: string;
|
|
98
|
+
};
|
|
99
|
+
props: {
|
|
100
|
+
entry: CollectionEntry<TContent>;
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export type { BoundGroupAccessor as B, CollectionHandle as C, DefineCollectionOptions as D, FieldScope as F, GroupDefinition as G, InferEntryContent as I, CollectionEntry as a, CollectionStaticPath as b, DualCallableHelper as c, FieldHelpersMap as d, FieldComponentProps as e, FieldReadOptions as f, GroupAccessor as g };
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { CmsAsset } from '@407dev/blocks';
|
|
2
|
+
|
|
3
|
+
interface RouteSeo {
|
|
4
|
+
title?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
canonical?: string;
|
|
7
|
+
og_image?: string | CmsAsset;
|
|
8
|
+
og_title?: string;
|
|
9
|
+
og_description?: string;
|
|
10
|
+
twitter_card?: 'summary' | 'summary_large_image' | string;
|
|
11
|
+
noindex?: boolean;
|
|
12
|
+
sitemap_changefreq?: 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';
|
|
13
|
+
sitemap_priority?: number;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}
|
|
16
|
+
interface CmsRedirect {
|
|
17
|
+
id?: string;
|
|
18
|
+
from_path: string;
|
|
19
|
+
to_path: string;
|
|
20
|
+
status_code: 301 | 302 | 307 | 308 | number;
|
|
21
|
+
enabled?: boolean;
|
|
22
|
+
order_key?: string;
|
|
23
|
+
}
|
|
24
|
+
interface CmsSiteConfig {
|
|
25
|
+
site_id?: string;
|
|
26
|
+
redirects: CmsRedirect[];
|
|
27
|
+
robots: {
|
|
28
|
+
rules?: Array<{
|
|
29
|
+
user_agent?: string;
|
|
30
|
+
allow?: string[];
|
|
31
|
+
disallow?: string[];
|
|
32
|
+
}>;
|
|
33
|
+
sitemap?: string | boolean;
|
|
34
|
+
raw?: string;
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
};
|
|
37
|
+
default_seo: RouteSeo;
|
|
38
|
+
sitemap: {
|
|
39
|
+
enabled?: boolean;
|
|
40
|
+
exclude?: string[];
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
};
|
|
43
|
+
not_found_path?: string | null;
|
|
44
|
+
version_number?: number;
|
|
45
|
+
published_at?: string;
|
|
46
|
+
}
|
|
47
|
+
interface ContentBundle {
|
|
48
|
+
bundleVersion: 1;
|
|
49
|
+
site_id: string;
|
|
50
|
+
fields: Record<string, unknown>;
|
|
51
|
+
collections: Record<string, {
|
|
52
|
+
presentation: 'visual' | 'form';
|
|
53
|
+
orderable: boolean;
|
|
54
|
+
route_pattern?: string | null;
|
|
55
|
+
schema_version: number;
|
|
56
|
+
title_field?: string | null;
|
|
57
|
+
list_columns?: string[] | null;
|
|
58
|
+
body_field?: string | null;
|
|
59
|
+
}>;
|
|
60
|
+
entries: Record<string, Array<{
|
|
61
|
+
slug: string;
|
|
62
|
+
content: Record<string, unknown>;
|
|
63
|
+
position?: string | null;
|
|
64
|
+
status: 'draft' | 'published' | 'scheduled';
|
|
65
|
+
published_at?: string | null;
|
|
66
|
+
}>>;
|
|
67
|
+
routes: Array<{
|
|
68
|
+
path?: string;
|
|
69
|
+
pattern?: string;
|
|
70
|
+
kind: 'static' | 'collection';
|
|
71
|
+
collection?: string | null;
|
|
72
|
+
sourcePath?: string;
|
|
73
|
+
}>;
|
|
74
|
+
settings: {
|
|
75
|
+
robots?: Record<string, unknown>;
|
|
76
|
+
default_seo?: RouteSeo;
|
|
77
|
+
sitemap?: Record<string, unknown>;
|
|
78
|
+
not_found_path?: string | null;
|
|
79
|
+
};
|
|
80
|
+
redirects: Array<{
|
|
81
|
+
id: string;
|
|
82
|
+
from_path: string;
|
|
83
|
+
to_path: string;
|
|
84
|
+
status_code: number;
|
|
85
|
+
enabled: boolean;
|
|
86
|
+
order_key: string;
|
|
87
|
+
}>;
|
|
88
|
+
}
|
|
89
|
+
interface CmsClientConfig {
|
|
90
|
+
siteId: string;
|
|
91
|
+
contentUrl: string;
|
|
92
|
+
previewSecret?: string;
|
|
93
|
+
fetch?: typeof fetch;
|
|
94
|
+
}
|
|
95
|
+
interface GetBundleOptions {
|
|
96
|
+
previewToken?: string | null;
|
|
97
|
+
}
|
|
98
|
+
interface CmsClient {
|
|
99
|
+
readonly siteId: string;
|
|
100
|
+
readonly contentUrl: string;
|
|
101
|
+
readonly previewSecret?: string;
|
|
102
|
+
getBundle(options?: GetBundleOptions): Promise<ContentBundle>;
|
|
103
|
+
getFields(options?: GetBundleOptions): Promise<Record<string, unknown>>;
|
|
104
|
+
getField<T = unknown>(key: string, options?: GetBundleOptions): Promise<T | null>;
|
|
105
|
+
getCollections(options?: GetBundleOptions): Promise<ContentBundle['collections']>;
|
|
106
|
+
getEntries(collectionKey: string, options?: GetBundleOptions): Promise<ContentBundle['entries'][string]>;
|
|
107
|
+
getEntry(collectionKey: string, slug: string, options?: GetBundleOptions): Promise<ContentBundle['entries'][string][number] | null>;
|
|
108
|
+
getRoutes(options?: GetBundleOptions): Promise<ContentBundle['routes']>;
|
|
109
|
+
getSiteConfig(options?: GetBundleOptions): Promise<CmsSiteConfig>;
|
|
110
|
+
clearCache(): void;
|
|
111
|
+
}
|
|
112
|
+
interface PreviewTokenPayload {
|
|
113
|
+
site_id: string;
|
|
114
|
+
sub?: string;
|
|
115
|
+
iat?: number;
|
|
116
|
+
exp?: number;
|
|
117
|
+
[key: string]: unknown;
|
|
118
|
+
}
|
|
119
|
+
interface VerifyTokenResult {
|
|
120
|
+
valid: boolean;
|
|
121
|
+
payload?: PreviewTokenPayload;
|
|
122
|
+
error?: string;
|
|
123
|
+
}
|
|
124
|
+
interface CmsIntegrationOptions {
|
|
125
|
+
siteId?: string;
|
|
126
|
+
apiUrl?: string;
|
|
127
|
+
contentUrl?: string;
|
|
128
|
+
previewSecret?: string;
|
|
129
|
+
previewEntrypoint?: string;
|
|
130
|
+
injectPreviewRoute?: boolean;
|
|
131
|
+
client?: CmsClient;
|
|
132
|
+
emitRedirects?: boolean;
|
|
133
|
+
emitRobots?: boolean;
|
|
134
|
+
emitSitemap?: boolean;
|
|
135
|
+
siteUrl?: string;
|
|
136
|
+
editorOrigins?: string[];
|
|
137
|
+
}
|
|
138
|
+
type CmsAstroOptions = CmsIntegrationOptions;
|
|
139
|
+
|
|
140
|
+
export type { CmsClient as C, GetBundleOptions as G, PreviewTokenPayload as P, RouteSeo as R, VerifyTokenResult as V, CmsClientConfig as a, CmsSiteConfig as b, CmsAstroOptions as c, ContentBundle as d, CmsRedirect as e, CmsIntegrationOptions as f };
|
package/package.json
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@407dev/cms-astro",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/407dev/cms.git",
|
|
8
|
+
"directory": "packages/astro"
|
|
9
|
+
},
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"source": "./src/index.ts",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./collections": {
|
|
20
|
+
"source": "./src/fields/collections.ts",
|
|
21
|
+
"types": "./dist/fields/collections.d.ts",
|
|
22
|
+
"import": "./dist/fields/collections.js"
|
|
23
|
+
},
|
|
24
|
+
"./CmsImage.astro": "./src/CmsImage.astro",
|
|
25
|
+
"./CmsVideo.astro": "./src/CmsVideo.astro",
|
|
26
|
+
"./CmsHead.astro": "./src/CmsHead.astro",
|
|
27
|
+
"./RichText.astro": "./src/RichText.astro",
|
|
28
|
+
"./middleware": {
|
|
29
|
+
"source": "./src/middleware/index.ts",
|
|
30
|
+
"types": "./dist/middleware/index.d.ts",
|
|
31
|
+
"import": "./dist/middleware/index.js",
|
|
32
|
+
"default": "./dist/middleware/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./toolbar": {
|
|
35
|
+
"source": "./src/toolbar/app.ts",
|
|
36
|
+
"types": "./dist/toolbar/app.d.ts",
|
|
37
|
+
"import": "./dist/toolbar/app.js",
|
|
38
|
+
"default": "./dist/toolbar/app.js"
|
|
39
|
+
},
|
|
40
|
+
"./dev": {
|
|
41
|
+
"source": "./src/dev/index.ts",
|
|
42
|
+
"types": "./dist/dev/index.d.ts",
|
|
43
|
+
"import": "./dist/dev/index.js",
|
|
44
|
+
"default": "./dist/dev/index.js"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
49
|
+
},
|
|
50
|
+
"files": [
|
|
51
|
+
"dist",
|
|
52
|
+
"src"
|
|
53
|
+
],
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"zod": "^4.4.3",
|
|
56
|
+
"@407dev/blocks": "0.1.0",
|
|
57
|
+
"@407dev/field-types": "0.1.0"
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"astro": "^5.0.0",
|
|
61
|
+
"@407dev/cli": "0.1.0"
|
|
62
|
+
},
|
|
63
|
+
"peerDependenciesMeta": {
|
|
64
|
+
"@407dev/cli": {
|
|
65
|
+
"optional": true
|
|
66
|
+
},
|
|
67
|
+
"astro": {
|
|
68
|
+
"optional": true
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"devDependencies": {
|
|
72
|
+
"astro": "^5.3.0",
|
|
73
|
+
"expect-type": "^0.20.0",
|
|
74
|
+
"tsup": "^8.4.0",
|
|
75
|
+
"typescript": "^5.7.3",
|
|
76
|
+
"vite": "^6.1.0",
|
|
77
|
+
"vitest": "3.0.7",
|
|
78
|
+
"@407dev/api-client": "0.0.1",
|
|
79
|
+
"@407dev/cli": "0.1.0",
|
|
80
|
+
"@407dev/config": "0.0.1",
|
|
81
|
+
"@407dev/design-tokens": "0.0.1"
|
|
82
|
+
},
|
|
83
|
+
"scripts": {
|
|
84
|
+
"build": "tsup",
|
|
85
|
+
"dev": "tsup --watch",
|
|
86
|
+
"lint": "biome check src",
|
|
87
|
+
"typecheck": "tsc --noEmit",
|
|
88
|
+
"test": "vitest run"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { buildHeadTags } from './head';
|
|
3
|
+
import type { CmsRoute, CmsSiteConfig } from './types';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
route?: CmsRoute | null;
|
|
7
|
+
siteConfig?: CmsSiteConfig | null;
|
|
8
|
+
siteUrl?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const { route, siteConfig, siteUrl } = Astro.props;
|
|
12
|
+
const tags = buildHeadTags(route, siteConfig, { siteUrl });
|
|
13
|
+
---
|
|
14
|
+
{tags.map((t) => {
|
|
15
|
+
if (t.tag === 'title') {
|
|
16
|
+
return <title>{t.content}</title>;
|
|
17
|
+
}
|
|
18
|
+
if (t.tag === 'meta') {
|
|
19
|
+
return <meta {...t.attrs} />;
|
|
20
|
+
}
|
|
21
|
+
if (t.tag === 'link') {
|
|
22
|
+
return <link {...t.attrs} />;
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
})}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { CmsAsset } from '@407dev/blocks';
|
|
3
|
+
import { buildCdnImageUrl, buildSrcSet, isCdnTransformableUrl } from './image';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
src: CmsAsset | string;
|
|
7
|
+
alt: string;
|
|
8
|
+
widths?: number[];
|
|
9
|
+
sizes?: string;
|
|
10
|
+
loading?: 'lazy' | 'eager';
|
|
11
|
+
class?: string;
|
|
12
|
+
style?: string;
|
|
13
|
+
width?: number;
|
|
14
|
+
height?: number;
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
src,
|
|
20
|
+
alt,
|
|
21
|
+
widths = [400, 800, 1200, 1600],
|
|
22
|
+
sizes = '100vw',
|
|
23
|
+
loading = 'lazy',
|
|
24
|
+
class: className,
|
|
25
|
+
style: userStyle = '',
|
|
26
|
+
width: explicitWidth,
|
|
27
|
+
height: explicitHeight,
|
|
28
|
+
...rest
|
|
29
|
+
} = Astro.props;
|
|
30
|
+
|
|
31
|
+
const isAsset = typeof src === 'object' && src !== null;
|
|
32
|
+
const asset = isAsset ? (src as CmsAsset) : null;
|
|
33
|
+
const rawUrl = asset ? asset.url : (src as string);
|
|
34
|
+
const altText = alt ?? asset?.alt ?? '';
|
|
35
|
+
const intrinsicWidth = explicitWidth ?? asset?.width ?? undefined;
|
|
36
|
+
const intrinsicHeight = explicitHeight ?? asset?.height ?? undefined;
|
|
37
|
+
|
|
38
|
+
let focalStyle = '';
|
|
39
|
+
if (asset && asset.focal_x !== undefined && asset.focal_y !== undefined) {
|
|
40
|
+
focalStyle = `object-position: ${Math.round(asset.focal_x * 100)}% ${Math.round(asset.focal_y * 100)}%;`;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const combinedStyle = [focalStyle, userStyle].filter(Boolean).join(' ');
|
|
44
|
+
const canTransform = isCdnTransformableUrl(rawUrl);
|
|
45
|
+
const srcset = canTransform ? buildSrcSet(rawUrl, widths) : undefined;
|
|
46
|
+
const defaultSrc =
|
|
47
|
+
canTransform && widths.length > 0
|
|
48
|
+
? buildCdnImageUrl(rawUrl, { width: widths[1] || widths[0] })
|
|
49
|
+
: rawUrl;
|
|
50
|
+
---
|
|
51
|
+
<img
|
|
52
|
+
src={defaultSrc}
|
|
53
|
+
srcset={srcset}
|
|
54
|
+
sizes={srcset ? sizes : undefined}
|
|
55
|
+
alt={altText}
|
|
56
|
+
width={intrinsicWidth}
|
|
57
|
+
height={intrinsicHeight}
|
|
58
|
+
loading={loading}
|
|
59
|
+
class={className}
|
|
60
|
+
style={combinedStyle || undefined}
|
|
61
|
+
{...rest}
|
|
62
|
+
/>
|