canopycms 0.0.62 → 0.0.63
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/dist/ai/index.d.ts +9 -0
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +9 -0
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/to-plain-text.d.ts +57 -0
- package/dist/ai/to-plain-text.d.ts.map +1 -0
- package/dist/ai/to-plain-text.js +255 -0
- package/dist/ai/to-plain-text.js.map +1 -0
- package/dist/ai/transform-components.d.ts.map +1 -1
- package/dist/ai/transform-components.js +70 -5
- package/dist/ai/transform-components.js.map +1 -1
- package/dist/api/comments.d.ts +2 -2
- package/dist/authorization/branch.d.ts +55 -3
- package/dist/authorization/branch.d.ts.map +1 -1
- package/dist/authorization/branch.js +55 -9
- package/dist/authorization/branch.js.map +1 -1
- package/dist/authorization/types.d.ts +1 -1
- package/dist/authorization/types.d.ts.map +1 -1
- package/dist/build-canopy.d.ts +49 -0
- package/dist/build-canopy.d.ts.map +1 -0
- package/dist/build-canopy.js +51 -0
- package/dist/build-canopy.js.map +1 -0
- package/dist/cli/cli.js +78 -26
- package/dist/cli/generate-ai-content.js +77 -25
- package/dist/cli/template-files/canopycms.config.ts.template +18 -1
- package/dist/content-listing.d.ts +110 -5
- package/dist/content-listing.d.ts.map +1 -1
- package/dist/content-listing.js +164 -23
- package/dist/content-listing.js.map +1 -1
- package/dist/content-reader.d.ts +41 -4
- package/dist/content-reader.d.ts.map +1 -1
- package/dist/content-reader.js +17 -4
- package/dist/content-reader.js.map +1 -1
- package/dist/content-store.d.ts +10 -1
- package/dist/content-store.d.ts.map +1 -1
- package/dist/content-store.js.map +1 -1
- package/dist/content-tree.d.ts +31 -2
- package/dist/content-tree.d.ts.map +1 -1
- package/dist/content-tree.js +22 -5
- package/dist/content-tree.js.map +1 -1
- package/dist/context.d.ts +30 -10
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +55 -4
- package/dist/context.js.map +1 -1
- package/dist/entry-schema.d.ts +228 -8
- package/dist/entry-schema.d.ts.map +1 -1
- package/dist/entry-schema.js +124 -0
- package/dist/entry-schema.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +51 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +49 -0
- package/dist/server.js.map +1 -1
- package/dist/services.d.ts +1 -2
- package/dist/services.d.ts.map +1 -1
- package/dist/services.js +2 -6
- package/dist/services.js.map +1 -1
- package/dist/static/index.d.ts +65 -5
- package/dist/static/index.d.ts.map +1 -1
- package/dist/static/index.js +65 -12
- package/dist/static/index.js.map +1 -1
- package/dist/static/seo.d.ts +150 -0
- package/dist/static/seo.d.ts.map +1 -0
- package/dist/static/seo.js +189 -0
- package/dist/static/seo.js.map +1 -0
- package/dist/utils/sanitize-href.d.ts +46 -0
- package/dist/utils/sanitize-href.d.ts.map +1 -1
- package/dist/utils/sanitize-href.js +63 -2
- package/dist/utils/sanitize-href.js.map +1 -1
- package/package.json +1 -1
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAA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AAE,aAAa,EAAE,CAAC,YAAY,EAAE,EAAE,CAAC,WAAW,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,OAAO,EAAE,CAAA;QACvF,CAAC,CAAA;QACD,MAAM,iBAAiB,GAAG,GAAG,EAAE;YAC7B,IAAI,CAAC,iBAAiB,EAAE,CAAC;gBACvB,iBAAiB,GAAG,qBAAqB,EAAE,CAAA;YAC7C,CAAC;YACD,OAAO,iBAAiB,CAAA;QAC1B,CAAC,CAAA;QAED,MAAM,gBAAgB,GAAsC,KAAK,EAI/D,OAAiD,EACjD,EAAE;YACF,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,MAAM,oBAAoB,EAAE,CAAA;YAChF,OAAO,oBAAoB,CACzB,UAAU,EACV,UAAU,EACV,eAAe,EACf,OAAO,EACP,MAAM,iBAAiB,EAAE,CAC1B,CAAA;QACH,CAAC,CAAA;QAED,MAAM,WAAW,GAAiC,KAAK,EACrD,OAA+B,EAC/B,EAAE;YACF,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,MAAM,oBAAoB,EAAE,CAAA;YAChF,OAAO,eAAe,CACpB,UAAU,EACV,UAAU,EACV,eAAe,EACf,OAAO,EACP,MAAM,iBAAiB,EAAE,CAC1B,CAAA;QACH,CAAC,CAAA;QAED,OAAO;YACL,IAAI;YACJ,aAAa;YACb,gBAAgB;YAChB,WAAW;YACX,QAAQ;YACR,IAAI;SACL,CAAA;IACH,CAAC,CAAA;IAED,OAAO;QACL,UAAU;QACV,QAAQ;KACT,CAAA;AACH,CAAC"}
|
package/dist/entry-schema.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
1
2
|
/** Structural constraint for fields that can be inferred by TypeFromEntrySchema. */
|
|
2
3
|
type InferableField = {
|
|
3
4
|
name: string;
|
|
@@ -30,11 +31,24 @@ type FlattenInlineGroups<Fields extends readonly InferableField[]> = Fields exte
|
|
|
30
31
|
type: 'group';
|
|
31
32
|
fields: infer GFields extends readonly InferableField[];
|
|
32
33
|
} ? [...FlattenInlineGroups<GFields>, ...FlattenInlineGroups<Rest>] : [Head, ...FlattenInlineGroups<Rest>] : [];
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Collapse an intersection of mapped types into one object type, preserving the `?`
|
|
36
|
+
* modifier (the mapped type is homomorphic over `keyof T`, so optionality survives).
|
|
37
|
+
* Without it, InferContentShape would surface as `{ a: string } & { b?: string }` —
|
|
38
|
+
* structurally equivalent, but it reads badly in editor tooltips and is not accepted
|
|
39
|
+
* by strict type-equality assertions.
|
|
40
|
+
*/
|
|
41
|
+
type Simplify<T> = {
|
|
42
|
+
[K in keyof T]: T[K];
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* The value type of a field, WITHOUT any optionality. Optionality is carried solely by
|
|
46
|
+
* the `?` modifier that InferContentShape applies, never duplicated as `| undefined`.
|
|
47
|
+
*/
|
|
48
|
+
type ScalarValue<F extends InferableField, V> = F['list'] extends true ? V[] : V;
|
|
35
49
|
type ObjectValue<F extends InferableField & {
|
|
36
50
|
fields: readonly InferableField[];
|
|
37
|
-
}> =
|
|
51
|
+
}> = F['list'] extends true ? Array<InferContentShape<F['fields']>> : InferContentShape<F['fields']>;
|
|
38
52
|
/**
|
|
39
53
|
* Distributes over each member of a block templates union to produce a discriminated union.
|
|
40
54
|
*
|
|
@@ -55,7 +69,7 @@ type BlockValue<F extends InferableField & {
|
|
|
55
69
|
name: string;
|
|
56
70
|
fields: readonly InferableField[];
|
|
57
71
|
}>;
|
|
58
|
-
}> =
|
|
72
|
+
}> = Array<DistributeBlockTemplate<F['templates'][number]>>;
|
|
59
73
|
/**
|
|
60
74
|
* Structural mirror of `ImageFieldValue` (config/types.ts). Kept inline
|
|
61
75
|
* rather than imported so this module stays free of a FieldConfig import
|
|
@@ -107,15 +121,23 @@ type FieldValue<F extends InferableField> = F extends {
|
|
|
107
121
|
* - Objects become nested objects
|
|
108
122
|
* - Blocks become arrays of tagged templates with their value shapes
|
|
109
123
|
* - Lists become arrays of the scalar/object type
|
|
110
|
-
* -
|
|
124
|
+
* - A field with an explicit `required: false` becomes an OPTIONAL property
|
|
125
|
+
* (`subheading?: string`), so a literal may omit it entirely rather than spelling it
|
|
126
|
+
* out as `undefined`. Reading it still yields `string | undefined`.
|
|
127
|
+
* - A field that OMITS `required` stays a REQUIRED property. `F['required']` infers as
|
|
128
|
+
* `boolean | undefined` there, which does not extend `false`. This three-way
|
|
129
|
+
* distinction (`true` / `false` / absent) is deliberate and pinned by tests — only an
|
|
130
|
+
* explicit `required: false` opts a key into `?:`.
|
|
111
131
|
* - Inline groups (type: 'group') are flattened — their fields contribute directly
|
|
112
132
|
* to the parent shape with no intermediate key.
|
|
113
133
|
*
|
|
114
134
|
* Works with any structurally compatible array; importing FieldConfig is not required.
|
|
115
135
|
*/
|
|
116
|
-
type InferContentShape<Fields extends readonly InferableField[]> = {
|
|
117
|
-
[F in FlattenInlineGroups<Fields>[number] as F['name']]: FieldValue<F>;
|
|
118
|
-
}
|
|
136
|
+
type InferContentShape<Fields extends readonly InferableField[]> = Simplify<{
|
|
137
|
+
[F in FlattenInlineGroups<Fields>[number] as F['required'] extends false ? never : F['name']]: FieldValue<F>;
|
|
138
|
+
} & {
|
|
139
|
+
[F in FlattenInlineGroups<Fields>[number] as F['required'] extends false ? F['name'] : never]?: FieldValue<F>;
|
|
140
|
+
}>;
|
|
119
141
|
/**
|
|
120
142
|
* Helper to define entry schema field arrays with literal inference without sprinkling `as const`.
|
|
121
143
|
*/
|
|
@@ -187,6 +209,117 @@ export declare const defineInlineFieldGroup: <const T extends {
|
|
|
187
209
|
}>(group: T) => T & {
|
|
188
210
|
readonly type: "group";
|
|
189
211
|
};
|
|
212
|
+
/**
|
|
213
|
+
* The recommended SEO field group, ready to drop into any entry schema.
|
|
214
|
+
*
|
|
215
|
+
* Emits the seven fields `extractSeoFields()` reads by default (`metaTitle`,
|
|
216
|
+
* `metaDescription`, `ogImage`, `ogType`, `canonical`, `noindex`, `twitterCard`), so schema and
|
|
217
|
+
* read side agree with no configuration. Every field is `required: false` — SEO metadata is
|
|
218
|
+
* always optional, and an unset field must fall back rather than fail validation.
|
|
219
|
+
*
|
|
220
|
+
* **Flat by default.** The fields are stored flat in the content file (an inline group: a
|
|
221
|
+
* visual container in the editor that adds no data key). Pass `group: 'seo'` for the nested
|
|
222
|
+
* convention, which stores them under that key — and then pass the same `{ group: 'seo' }` to
|
|
223
|
+
* `extractSeoFields` / `entryToMetadata`.
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* // Flat (recommended): frontmatter carries `metaTitle:` at the top level.
|
|
227
|
+
* const pageSchema = defineEntrySchema([
|
|
228
|
+
* { name: 'title', type: 'string' },
|
|
229
|
+
* defineSeoFieldGroup(),
|
|
230
|
+
* ])
|
|
231
|
+
* // TypeFromEntrySchema: { title: string; metaTitle?: string; metaDescription?: string; ... }
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* // Nested: frontmatter carries `seo: { metaTitle: … }`.
|
|
235
|
+
* const pageSchema = defineEntrySchema([defineSeoFieldGroup({ group: 'seo' })])
|
|
236
|
+
* const metadata = entryToMetadata(data, { group: 'seo' })
|
|
237
|
+
* // TypeFromEntrySchema: { seo?: { metaTitle?: string; ... } } — the wrapper key itself is
|
|
238
|
+
* // optional too, so an entry that sets no SEO fields at all can omit `seo` entirely.
|
|
239
|
+
*/
|
|
240
|
+
declare const SEO_GROUP_FIELDS: readonly [{
|
|
241
|
+
readonly name: "metaTitle";
|
|
242
|
+
readonly type: "string";
|
|
243
|
+
readonly label: "Meta Title";
|
|
244
|
+
readonly description: "Overrides the page title in search results and social cards.";
|
|
245
|
+
readonly required: false;
|
|
246
|
+
}, {
|
|
247
|
+
readonly name: "metaDescription";
|
|
248
|
+
readonly type: "string";
|
|
249
|
+
readonly label: "Meta Description";
|
|
250
|
+
readonly description: "Summary shown under the title in search results.";
|
|
251
|
+
readonly required: false;
|
|
252
|
+
}, {
|
|
253
|
+
readonly name: "ogImage";
|
|
254
|
+
readonly type: "string";
|
|
255
|
+
readonly label: "Social Image URL";
|
|
256
|
+
readonly description: "Image for social cards. Site-relative or absolute.";
|
|
257
|
+
readonly required: false;
|
|
258
|
+
}, {
|
|
259
|
+
readonly name: "ogType";
|
|
260
|
+
readonly type: "select";
|
|
261
|
+
readonly label: "OpenGraph Type";
|
|
262
|
+
readonly options: readonly ["website", "article", "profile"];
|
|
263
|
+
readonly required: false;
|
|
264
|
+
}, {
|
|
265
|
+
readonly name: "canonical";
|
|
266
|
+
readonly type: "string";
|
|
267
|
+
readonly label: "Canonical URL";
|
|
268
|
+
readonly description: "Set only to point at a different canonical copy of this page.";
|
|
269
|
+
readonly required: false;
|
|
270
|
+
}, {
|
|
271
|
+
readonly name: "noindex";
|
|
272
|
+
readonly type: "boolean";
|
|
273
|
+
readonly label: "Hide from search engines";
|
|
274
|
+
readonly description: "Marks the page noindex AND drops it from the sitemap.";
|
|
275
|
+
readonly required: false;
|
|
276
|
+
}, {
|
|
277
|
+
readonly name: "twitterCard";
|
|
278
|
+
readonly type: "select";
|
|
279
|
+
readonly label: "Twitter Card";
|
|
280
|
+
readonly options: readonly ["summary", "summary_large_image"];
|
|
281
|
+
readonly required: false;
|
|
282
|
+
}];
|
|
283
|
+
/** The seven recommended SEO fields, as a literal-typed field tuple. */
|
|
284
|
+
export type SeoGroupFields = typeof SEO_GROUP_FIELDS;
|
|
285
|
+
interface SeoFieldGroupOptions {
|
|
286
|
+
/** Editor label for the group. Default 'SEO'. */
|
|
287
|
+
label?: string;
|
|
288
|
+
/** Editor description for the group. */
|
|
289
|
+
description?: string;
|
|
290
|
+
}
|
|
291
|
+
/** Flat (inline) SEO group: fields are stored at the top level of the content file. */
|
|
292
|
+
export type InlineSeoFieldGroup = {
|
|
293
|
+
name: 'seo';
|
|
294
|
+
label: string;
|
|
295
|
+
description?: string;
|
|
296
|
+
fields: SeoGroupFields;
|
|
297
|
+
type: 'group';
|
|
298
|
+
};
|
|
299
|
+
/** Nested SEO group: fields are stored under the group's own key in the content file. */
|
|
300
|
+
export type NestedSeoFieldGroup<G extends string> = {
|
|
301
|
+
name: G;
|
|
302
|
+
label: string;
|
|
303
|
+
description?: string;
|
|
304
|
+
fields: SeoGroupFields;
|
|
305
|
+
type: 'object';
|
|
306
|
+
/**
|
|
307
|
+
* The wrapper object itself is optional — an entry that sets no SEO fields at all omits the
|
|
308
|
+
* `seo` key entirely, matching the runtime validator (`entry-validator.ts`), which only
|
|
309
|
+
* enforces fields with `required: true`.
|
|
310
|
+
*/
|
|
311
|
+
required: false;
|
|
312
|
+
};
|
|
313
|
+
export declare function defineSeoFieldGroup(opts?: SeoFieldGroupOptions & {
|
|
314
|
+
group?: undefined;
|
|
315
|
+
}): InlineSeoFieldGroup;
|
|
316
|
+
export declare function defineSeoFieldGroup<const G extends string>(opts: SeoFieldGroupOptions & {
|
|
317
|
+
/**
|
|
318
|
+
* Nest the fields under this data key instead of storing them flat. Must match the `group`
|
|
319
|
+
* option passed to `extractSeoFields` / `entryToMetadata`.
|
|
320
|
+
*/
|
|
321
|
+
group: G;
|
|
322
|
+
}): NestedSeoFieldGroup<G>;
|
|
190
323
|
/**
|
|
191
324
|
* Define a reusable nested field group — a visual container in the editor that groups
|
|
192
325
|
* related fields under a named key in the content file.
|
|
@@ -250,5 +383,92 @@ export declare const defineBlockTemplate: <const T extends {
|
|
|
250
383
|
description?: string;
|
|
251
384
|
fields: readonly InferableField[];
|
|
252
385
|
}>(template: T) => T;
|
|
386
|
+
/**
|
|
387
|
+
* Extract one template's value shape out of a block field's discriminated union.
|
|
388
|
+
*
|
|
389
|
+
* `Blocks` is the union itself — e.g. `Page['sections'][number]`, the element type of
|
|
390
|
+
* a `block` field as derived by `TypeFromEntrySchema` — not the surrounding array.
|
|
391
|
+
* `N` is one of that union's `template` literals.
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* const heroBlock = defineBlockTemplate({
|
|
395
|
+
* name: 'hero',
|
|
396
|
+
* fields: [{ name: 'headline', type: 'string' }],
|
|
397
|
+
* })
|
|
398
|
+
* const pageSchema = defineEntrySchema([
|
|
399
|
+
* { name: 'sections', type: 'block', templates: [heroBlock] },
|
|
400
|
+
* ])
|
|
401
|
+
* type Sections = TypeFromEntrySchema<typeof pageSchema>['sections'][number]
|
|
402
|
+
* type HeroValue = BlockValueOf<Sections, 'hero'> // { headline: string }
|
|
403
|
+
*/
|
|
404
|
+
export type BlockValueOf<Blocks extends {
|
|
405
|
+
template: string;
|
|
406
|
+
value: unknown;
|
|
407
|
+
}, N extends Blocks['template']> = Extract<Blocks, {
|
|
408
|
+
template: N;
|
|
409
|
+
}>['value'];
|
|
410
|
+
/**
|
|
411
|
+
* A mapped type over a block field's template names, requiring exactly one component
|
|
412
|
+
* per template — no more, no fewer. This makes a block → component registry exhaustive
|
|
413
|
+
* *by construction*: adding a template to the schema without adding its component is a
|
|
414
|
+
* compile error, and a stray/renamed key in the registry is a compile error too. That is
|
|
415
|
+
* strictly stronger than a runtime "did I handle every template?" guard, since it fails
|
|
416
|
+
* the build instead of failing silently at render time.
|
|
417
|
+
*
|
|
418
|
+
* Deliberately a type, not a `renderBlocks()` helper — the type says nothing about key
|
|
419
|
+
* strategy, unknown-template handling, or how extra props reach each component, so it
|
|
420
|
+
* imposes no rendering shape. Adopters write their own small loop (see the README's
|
|
421
|
+
* "Block Component Registries" section for the recipe) and get exhaustiveness for free.
|
|
422
|
+
*
|
|
423
|
+
* @example
|
|
424
|
+
* const registry: BlockComponentRegistry<Sections> = {
|
|
425
|
+
* hero: ({ data }) => <HeroSection {...data} />,
|
|
426
|
+
* // TS error here if 'hero' is missing, or if a key doesn't match a template name.
|
|
427
|
+
* }
|
|
428
|
+
*
|
|
429
|
+
* // With extra props threaded to every block component:
|
|
430
|
+
* type Props = { index: number }
|
|
431
|
+
* const registryWithProps: BlockComponentRegistry<Sections, Props> = {
|
|
432
|
+
* hero: ({ data, index }) => <HeroSection {...data} position={index} />,
|
|
433
|
+
* }
|
|
434
|
+
*/
|
|
435
|
+
export type BlockComponentRegistry<Blocks extends {
|
|
436
|
+
template: string;
|
|
437
|
+
value: unknown;
|
|
438
|
+
}, ExtraProps extends object = object> = {
|
|
439
|
+
[N in Blocks['template']]: ComponentType<{
|
|
440
|
+
data: BlockValueOf<Blocks, N>;
|
|
441
|
+
} & ExtraProps>;
|
|
442
|
+
};
|
|
443
|
+
/**
|
|
444
|
+
* Const-inference identity helper for a reusable field fragment — a plain array of field
|
|
445
|
+
* configs (not a group, not a template) that you spread into multiple schemas' `fields`.
|
|
446
|
+
* Exists purely for discoverability: `defineEntrySchema` and `defineBlockTemplate` already
|
|
447
|
+
* infer literal types from a `const fields = [...] as const` array, so spreading it works
|
|
448
|
+
* without this helper too. Wrapping the definition site in `defineFieldFragment(...)` just
|
|
449
|
+
* makes the pattern easy to find (and to grep for) alongside `defineInlineFieldGroup` and
|
|
450
|
+
* `defineNestedFieldGroup`.
|
|
451
|
+
*
|
|
452
|
+
* Use this over a field group when you don't want the fields visually boxed together in
|
|
453
|
+
* the editor, or when different schemas need to override one field (e.g. a different
|
|
454
|
+
* `label` or `required`) — spread the fragment, then follow it with an object that
|
|
455
|
+
* overrides just the field(s) that differ for that schema.
|
|
456
|
+
*
|
|
457
|
+
* @example
|
|
458
|
+
* const ctaFields = defineFieldFragment([
|
|
459
|
+
* { name: 'ctaLabel', type: 'string', label: 'Button Label' },
|
|
460
|
+
* { name: 'ctaHref', type: 'string', label: 'Button Link' },
|
|
461
|
+
* ])
|
|
462
|
+
*
|
|
463
|
+
* const heroSchema = defineEntrySchema([
|
|
464
|
+
* { name: 'headline', type: 'string' },
|
|
465
|
+
* ...ctaFields,
|
|
466
|
+
* ])
|
|
467
|
+
* const bannerSchema = defineEntrySchema([
|
|
468
|
+
* { name: 'message', type: 'string' },
|
|
469
|
+
* ...ctaFields,
|
|
470
|
+
* ])
|
|
471
|
+
*/
|
|
472
|
+
export declare const defineFieldFragment: <const T extends readonly InferableField[]>(fields: T) => T;
|
|
253
473
|
export {};
|
|
254
474
|
//# sourceMappingURL=entry-schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry-schema.d.ts","sourceRoot":"","sources":["../src/entry-schema.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,KAAK,cAAc,GAAG;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,SAAS,cAAc,EAAE,CAAA;IAClC,SAAS,CAAC,EAAE,aAAa,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,SAAS,cAAc,EAAE,CAAA;KAAE,CAAC,CAAA;IAC9E,6GAA6G;IAC7G,cAAc,CAAC,EAAE,SAAS,cAAc,EAAE,CAAA;IAC1C,2EAA2E;IAC3E,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAC9B,kEAAkE;IAClE,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAChC,CAAA;AAED;;;;GAIG;AACH,KAAK,mBAAmB,CAAC,MAAM,SAAS,SAAS,cAAc,EAAE,IAAI,MAAM,SAAS,SAAS;IAC3F,MAAM,IAAI;IACV,GAAG,MAAM,IAAI,SAAS,SAAS,cAAc,EAAE;CAChD,GACG,IAAI,SAAS;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,OAAO,SAAS,SAAS,cAAc,EAAE,CAAA;CAAE,GACrF,CAAC,GAAG,mBAAmB,CAAC,OAAO,CAAC,EAAE,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC,GAC/D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,CAAA;CAAE,CAAC,CAAC,OAAO,CAAC,CAAA;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,sBAAsB,CAChC,MAAM,SAAS;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,EACnD,UAAU,SAAS,MAAM,GAAG,MAAM,IAChC;KACD,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,aAAa,CAAC;QAAE,IAAI,EAAE,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;KAAE,GAAG,UAAU,CAAC;CACzF,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,mBAAmB,GAAI,KAAK,CAAC,CAAC,SAAS,SAAS,cAAc,EAAE,EAAE,QAAQ,CAAC,KAAG,CACnF,CAAA"}
|
package/dist/entry-schema.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// The recommended SEO field names, shared with the read side (extractSeoFields) so the schema
|
|
2
|
+
// this module emits and the fields that module looks for cannot drift apart.
|
|
3
|
+
import { DEFAULT_SEO_FIELD_NAMES } from './static/seo.js';
|
|
1
4
|
/**
|
|
2
5
|
* Helper to define entry schema field arrays with literal inference without sprinkling `as const`.
|
|
3
6
|
*/
|
|
@@ -24,6 +27,97 @@ export const defineEntrySchema = (fields) => fields;
|
|
|
24
27
|
* // TypeFromEntrySchema: { ..., metaTitle: string, metaDescription: string }
|
|
25
28
|
*/
|
|
26
29
|
export const defineInlineFieldGroup = (group) => ({ ...group, type: 'group' });
|
|
30
|
+
/**
|
|
31
|
+
* The recommended SEO field group, ready to drop into any entry schema.
|
|
32
|
+
*
|
|
33
|
+
* Emits the seven fields `extractSeoFields()` reads by default (`metaTitle`,
|
|
34
|
+
* `metaDescription`, `ogImage`, `ogType`, `canonical`, `noindex`, `twitterCard`), so schema and
|
|
35
|
+
* read side agree with no configuration. Every field is `required: false` — SEO metadata is
|
|
36
|
+
* always optional, and an unset field must fall back rather than fail validation.
|
|
37
|
+
*
|
|
38
|
+
* **Flat by default.** The fields are stored flat in the content file (an inline group: a
|
|
39
|
+
* visual container in the editor that adds no data key). Pass `group: 'seo'` for the nested
|
|
40
|
+
* convention, which stores them under that key — and then pass the same `{ group: 'seo' }` to
|
|
41
|
+
* `extractSeoFields` / `entryToMetadata`.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* // Flat (recommended): frontmatter carries `metaTitle:` at the top level.
|
|
45
|
+
* const pageSchema = defineEntrySchema([
|
|
46
|
+
* { name: 'title', type: 'string' },
|
|
47
|
+
* defineSeoFieldGroup(),
|
|
48
|
+
* ])
|
|
49
|
+
* // TypeFromEntrySchema: { title: string; metaTitle?: string; metaDescription?: string; ... }
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* // Nested: frontmatter carries `seo: { metaTitle: … }`.
|
|
53
|
+
* const pageSchema = defineEntrySchema([defineSeoFieldGroup({ group: 'seo' })])
|
|
54
|
+
* const metadata = entryToMetadata(data, { group: 'seo' })
|
|
55
|
+
* // TypeFromEntrySchema: { seo?: { metaTitle?: string; ... } } — the wrapper key itself is
|
|
56
|
+
* // optional too, so an entry that sets no SEO fields at all can omit `seo` entirely.
|
|
57
|
+
*/
|
|
58
|
+
const SEO_GROUP_FIELDS = [
|
|
59
|
+
{
|
|
60
|
+
name: DEFAULT_SEO_FIELD_NAMES.title,
|
|
61
|
+
type: 'string',
|
|
62
|
+
label: 'Meta Title',
|
|
63
|
+
description: 'Overrides the page title in search results and social cards.',
|
|
64
|
+
required: false,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: DEFAULT_SEO_FIELD_NAMES.description,
|
|
68
|
+
type: 'string',
|
|
69
|
+
label: 'Meta Description',
|
|
70
|
+
description: 'Summary shown under the title in search results.',
|
|
71
|
+
required: false,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: DEFAULT_SEO_FIELD_NAMES.ogImage,
|
|
75
|
+
type: 'string',
|
|
76
|
+
label: 'Social Image URL',
|
|
77
|
+
description: 'Image for social cards. Site-relative or absolute.',
|
|
78
|
+
required: false,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: DEFAULT_SEO_FIELD_NAMES.ogType,
|
|
82
|
+
type: 'select',
|
|
83
|
+
label: 'OpenGraph Type',
|
|
84
|
+
options: ['website', 'article', 'profile'],
|
|
85
|
+
required: false,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: DEFAULT_SEO_FIELD_NAMES.canonical,
|
|
89
|
+
type: 'string',
|
|
90
|
+
label: 'Canonical URL',
|
|
91
|
+
description: 'Set only to point at a different canonical copy of this page.',
|
|
92
|
+
required: false,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: DEFAULT_SEO_FIELD_NAMES.noindex,
|
|
96
|
+
type: 'boolean',
|
|
97
|
+
label: 'Hide from search engines',
|
|
98
|
+
description: 'Marks the page noindex AND drops it from the sitemap.',
|
|
99
|
+
required: false,
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: DEFAULT_SEO_FIELD_NAMES.twitterCard,
|
|
103
|
+
type: 'select',
|
|
104
|
+
label: 'Twitter Card',
|
|
105
|
+
options: ['summary', 'summary_large_image'],
|
|
106
|
+
required: false,
|
|
107
|
+
},
|
|
108
|
+
];
|
|
109
|
+
export function defineSeoFieldGroup(opts = {}) {
|
|
110
|
+
const base = {
|
|
111
|
+
label: opts.label ?? 'SEO',
|
|
112
|
+
...(opts.description ? { description: opts.description } : {}),
|
|
113
|
+
fields: SEO_GROUP_FIELDS,
|
|
114
|
+
};
|
|
115
|
+
// 'object' nests the fields under `name`; 'group' is the inline (flat) container, whose name
|
|
116
|
+
// is an editor-only label anchor and contributes no key to the content file.
|
|
117
|
+
return opts.group
|
|
118
|
+
? { ...base, name: opts.group, type: 'object', required: false }
|
|
119
|
+
: { ...base, name: 'seo', type: 'group' };
|
|
120
|
+
}
|
|
27
121
|
/**
|
|
28
122
|
* Define a reusable nested field group — a visual container in the editor that groups
|
|
29
123
|
* related fields under a named key in the content file.
|
|
@@ -78,4 +172,34 @@ export const defineNestedFieldGroup = (group) => ({ ...group, type: 'object' });
|
|
|
78
172
|
* // | { template: 'cta'; value: { label: string; href: string } }>
|
|
79
173
|
*/
|
|
80
174
|
export const defineBlockTemplate = (template) => template;
|
|
175
|
+
/**
|
|
176
|
+
* Const-inference identity helper for a reusable field fragment — a plain array of field
|
|
177
|
+
* configs (not a group, not a template) that you spread into multiple schemas' `fields`.
|
|
178
|
+
* Exists purely for discoverability: `defineEntrySchema` and `defineBlockTemplate` already
|
|
179
|
+
* infer literal types from a `const fields = [...] as const` array, so spreading it works
|
|
180
|
+
* without this helper too. Wrapping the definition site in `defineFieldFragment(...)` just
|
|
181
|
+
* makes the pattern easy to find (and to grep for) alongside `defineInlineFieldGroup` and
|
|
182
|
+
* `defineNestedFieldGroup`.
|
|
183
|
+
*
|
|
184
|
+
* Use this over a field group when you don't want the fields visually boxed together in
|
|
185
|
+
* the editor, or when different schemas need to override one field (e.g. a different
|
|
186
|
+
* `label` or `required`) — spread the fragment, then follow it with an object that
|
|
187
|
+
* overrides just the field(s) that differ for that schema.
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* const ctaFields = defineFieldFragment([
|
|
191
|
+
* { name: 'ctaLabel', type: 'string', label: 'Button Label' },
|
|
192
|
+
* { name: 'ctaHref', type: 'string', label: 'Button Link' },
|
|
193
|
+
* ])
|
|
194
|
+
*
|
|
195
|
+
* const heroSchema = defineEntrySchema([
|
|
196
|
+
* { name: 'headline', type: 'string' },
|
|
197
|
+
* ...ctaFields,
|
|
198
|
+
* ])
|
|
199
|
+
* const bannerSchema = defineEntrySchema([
|
|
200
|
+
* { name: 'message', type: 'string' },
|
|
201
|
+
* ...ctaFields,
|
|
202
|
+
* ])
|
|
203
|
+
*/
|
|
204
|
+
export const defineFieldFragment = (fields) => fields;
|
|
81
205
|
//# sourceMappingURL=entry-schema.js.map
|
package/dist/entry-schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry-schema.js","sourceRoot":"","sources":["../src/entry-schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"entry-schema.js","sourceRoot":"","sources":["../src/entry-schema.ts"],"names":[],"mappings":"AACA,8FAA8F;AAC9F,6EAA6E;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAmJtD;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAA4C,MAAS,EAAK,EAAE,CAAC,MAAM,CAAA;AA0CpG;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAQpC,KAAQ,EACwB,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,OAAgB,EAAE,CAAC,CAAA;AAE3E;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,gBAAgB,GAAG;IACvB;QACE,IAAI,EAAE,uBAAuB,CAAC,KAAK;QACnC,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,YAAY;QACnB,WAAW,EAAE,8DAA8D;QAC3E,QAAQ,EAAE,KAAK;KAChB;IACD;QACE,IAAI,EAAE,uBAAuB,CAAC,WAAW;QACzC,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,kBAAkB;QACzB,WAAW,EAAE,kDAAkD;QAC/D,QAAQ,EAAE,KAAK;KAChB;IACD;QACE,IAAI,EAAE,uBAAuB,CAAC,OAAO;QACrC,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,kBAAkB;QACzB,WAAW,EAAE,oDAAoD;QACjE,QAAQ,EAAE,KAAK;KAChB;IACD;QACE,IAAI,EAAE,uBAAuB,CAAC,MAAM;QACpC,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,gBAAgB;QACvB,OAAO,EAAE,CA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AE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,QAAiB,EAAE,CAAC,CAAA;AAE7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAQjC,QAAW,EACR,EAAE,CAAC,QAAQ,CAAA;AAyDhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAA4C,MAAS,EAAK,EAAE,CAC7F,MAAM,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from './config';
|
|
|
3
3
|
export * from './entry-schema';
|
|
4
4
|
export * from './types';
|
|
5
5
|
export * from './user';
|
|
6
|
+
export { resolveEntryTitle } from './utils/title-field';
|
|
6
7
|
export { defineAIContentConfig } from './ai/types';
|
|
7
8
|
export type { AIContentConfig, ExcludeConfig, BundleConfig, BundleFilter, FieldTransformFn, FieldTransforms, } from './ai/types';
|
|
8
9
|
export type { AuthPlugin, AuthPluginFactory } from './auth/plugin';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AAOtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAGvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAClD,YAAY,EACV,eAAe,EACf,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,eAAe,GAChB,MAAM,YAAY,CAAA;AAGnB,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAClE,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACzF,OAAO,EACL,eAAe,EACf,aAAa,EACb,cAAc,EACd,mBAAmB,GACpB,MAAM,wBAAwB,CAAA;AAC/B,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACzD,YAAY,EACV,eAAe,EACf,uBAAuB,EACvB,sBAAsB,EACtB,YAAY,EACZ,iBAAiB,GAClB,MAAM,gBAAgB,CAAA;AACvB,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAI5E,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAC1D,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACnE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,13 @@ export * from './config/index.js';
|
|
|
3
3
|
export * from './entry-schema.js';
|
|
4
4
|
export * from './types.js';
|
|
5
5
|
export * from './user.js';
|
|
6
|
+
// Title-derivation fallback chain (schema isTitle field -> data.title/name ->
|
|
7
|
+
// entry-type label -> humanized slug -> "Untitled"). Client-safe (its only
|
|
8
|
+
// import is `FieldConfig`/`InlineGroupFieldConfig` types, erased at compile
|
|
9
|
+
// time, so no runtime dependency at all) — re-exported here as well as from
|
|
10
|
+
// 'canopycms/server' so client-side list/preview UI can compute the same
|
|
11
|
+
// display title as build scripts without a second implementation.
|
|
12
|
+
export { resolveEntryTitle } from './utils/title-field.js';
|
|
6
13
|
// AI content config helper — client-safe (no node: imports).
|
|
7
14
|
// Server-only AI features (handler, generator) are in 'canopycms/ai'.
|
|
8
15
|
export { defineAIContentConfig } from './ai/types.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,6DAA6D;AAC7D,sEAAsE;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAalD,OAAO,EACL,eAAe,EACf,aAAa,EACb,cAAc,EACd,mBAAmB,GACpB,MAAM,wBAAwB,CAAA;AAU/B,6EAA6E;AAC7E,sEAAsE;AACtE,yEAAyE;AACzE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,8EAA8E;AAC9E,2EAA2E;AAC3E,4EAA4E;AAC5E,4EAA4E;AAC5E,yEAAyE;AACzE,kEAAkE;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,6DAA6D;AAC7D,sEAAsE;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAalD,OAAO,EACL,eAAe,EACf,aAAa,EACb,cAAc,EACd,mBAAmB,GACpB,MAAM,wBAAwB,CAAA;AAU/B,6EAA6E;AAC7E,sEAAsE;AACtE,yEAAyE;AACzE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA"}
|
package/dist/server.d.ts
CHANGED
|
@@ -4,6 +4,16 @@ export * from './build-mode';
|
|
|
4
4
|
export * from './context';
|
|
5
5
|
export { operatingStrategy } from './operating-mode';
|
|
6
6
|
export * from './authorization/groups';
|
|
7
|
+
/**
|
|
8
|
+
* One-call factory for a **build/admin** Canopy context — for standalone
|
|
9
|
+
* scripts that run entirely outside a Next.js request or build phase (index
|
|
10
|
+
* builders, content audits, codegen, ad hoc reports). Reads the filesystem
|
|
11
|
+
* directly as a synthetic admin user and bypasses ALL branch/path ACLs —
|
|
12
|
+
* never use it in request-handling code. See the source JSDoc for the full
|
|
13
|
+
* security note and the `createNextCanopyContext().getCanopyForBuild()`
|
|
14
|
+
* comparison this mirrors.
|
|
15
|
+
*/
|
|
16
|
+
export { createBuildCanopy, type CreateBuildCanopyOptions } from './build-canopy';
|
|
7
17
|
/**
|
|
8
18
|
* Resolve a CanopyUser for a request: loads internal groups from the
|
|
9
19
|
* settings workspace (the single source of truth — never a content branch
|
|
@@ -43,6 +53,21 @@ export { validateEntrySchemaRegistry } from './entry-schema-registry';
|
|
|
43
53
|
* `buildContentTree`'s `TEntryTypes` generic.
|
|
44
54
|
*/
|
|
45
55
|
export type { EntryTypesFromRegistry } from './entry-schema';
|
|
56
|
+
/**
|
|
57
|
+
* Resolve a display title for an entry using the full fallback chain: a
|
|
58
|
+
* schema-marked `isTitle` field, then `data.title`/`data.name`, then an
|
|
59
|
+
* entry-type label, then a humanized slug, then `"Untitled"`. Useful
|
|
60
|
+
* anywhere an entry needs a display title without re-deriving this chain —
|
|
61
|
+
* search-document/index builders in particular, since a search UI needs a
|
|
62
|
+
* title for every result regardless of which field the schema uses.
|
|
63
|
+
*
|
|
64
|
+
* Client-safe (no dependencies beyond `FieldConfig`/`InlineGroupFieldConfig`
|
|
65
|
+
* type imports, which are erased at compile time) — also re-exported from
|
|
66
|
+
* the root `canopycms` entry for that reason. Exported here too because
|
|
67
|
+
* build/admin scripts (the primary reason this was unreachable before) are
|
|
68
|
+
* more likely to `import` from `canopycms/server` than the root entry.
|
|
69
|
+
*/
|
|
70
|
+
export { resolveEntryTitle } from './utils/title-field';
|
|
46
71
|
/** Generate a Canopy-format 12-character Base58 content ID. */
|
|
47
72
|
export { generateId } from './id';
|
|
48
73
|
/** Returns true if a string is a valid 12-character Base58 Canopy ID. */
|
|
@@ -59,9 +84,26 @@ export { isValidId } from './id';
|
|
|
59
84
|
*/
|
|
60
85
|
export { buildContentTree } from './content-tree';
|
|
61
86
|
export type { ContentTreeNode, BuildContentTreeOptions, ContentTreeExtractMeta, EntryTypeMap, DefaultEntryTypes, } from './content-tree';
|
|
87
|
+
/**
|
|
88
|
+
* `buildContentTree`'s default URL path builder: strips the `{contentRootName}/`
|
|
89
|
+
* prefix, collapses an entry's `index` slug to its parent collection's path, and
|
|
90
|
+
* lowercases the result. Call it from inside a custom `buildPath` to extend the
|
|
91
|
+
* default rather than reimplement it — `buildContentTree`'s `buildPath` option
|
|
92
|
+
* replaces the default outright, it does not compose with it.
|
|
93
|
+
*/
|
|
94
|
+
export { defaultBuildPath } from './content-tree';
|
|
62
95
|
/** List all content entries as a flat array. */
|
|
63
96
|
export { listEntries } from './content-listing';
|
|
64
97
|
export type { ListEntriesItem, ListEntriesOptions } from './content-listing';
|
|
98
|
+
/**
|
|
99
|
+
* Parse a content filename of the form `{type}.{slug}.{id}.{ext}` into its
|
|
100
|
+
* `{ type, slug, id }` parts. `id` must be a valid 12-character Base58 content ID
|
|
101
|
+
* (excludes the ambiguous characters `0`, `O`, `I`, `l`) or the parse fails.
|
|
102
|
+
* Pass `entryTypes` to also require `type` to match a known entry-type name;
|
|
103
|
+
* omit it to parse the filename shape without that check. See the source JSDoc
|
|
104
|
+
* for the full filename grammar.
|
|
105
|
+
*/
|
|
106
|
+
export { parseTypedFilename } from './content-listing';
|
|
65
107
|
/**
|
|
66
108
|
* Resolve a canopy entry-link to its URL. Pair with the field-walker variants
|
|
67
109
|
* (`resolveEntryLinksInText`, `resolveEntryLinksInData`) when rendering MDX
|
|
@@ -74,6 +116,15 @@ export { computeEntryUrl } from './utils/entry-url';
|
|
|
74
116
|
/** Collect static paths for `generateStaticParams` / sitemap emission. */
|
|
75
117
|
export { collectStaticPaths } from './static';
|
|
76
118
|
export type { StaticPathEntry, CollectStaticPathsOptions } from './static';
|
|
119
|
+
/** Enumerate routable entries WITH their data — the input to sitemaps, feeds and search indexes. */
|
|
120
|
+
export { collectRoutableEntries } from './static';
|
|
121
|
+
export type { RoutableEntry, CollectRoutableEntriesOptions } from './static';
|
|
122
|
+
/**
|
|
123
|
+
* SEO field extraction and URL shaping (framework-agnostic). `isNoindexEntry` is the single
|
|
124
|
+
* predicate behind both `robots: noindex` and sitemap exclusion.
|
|
125
|
+
*/
|
|
126
|
+
export { DEFAULT_SEO_FIELD_NAMES, extractSeoFields, isNoindexEntry, isAbsoluteUrl, withTrailingSlash, resolveSeoUrl, stripTrailingSlashes, } from './static';
|
|
127
|
+
export type { SeoFields, SeoFieldNames, SeoFieldLocation, SeoOgType, SeoTwitterCard, ExtractSeoFieldsOptions, ResolveSeoUrlOptions, } from './static';
|
|
77
128
|
/**
|
|
78
129
|
* Start a chokidar-backed watcher that detects divergence between the dev
|
|
79
130
|
* working tree and the resolved branch clone. Dev mode only.
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAMA,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,cAAc,wBAAwB,CAAA;AAEtC;;;;;;;GAOG;AACH,OAAO,EAAE,iBAAiB,EAAE,KAAK,qBAAqB,EAAE,M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