vite-plugin-decap-cms 0.3.0 → 0.4.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/dist/index.cjs +429 -318
- package/dist/index.d.cts +77 -24
- package/dist/index.d.ts +77 -24
- package/dist/index.js +423 -317
- package/package.json +15 -15
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
2
|
import * as yaml from 'yaml';
|
|
3
|
+
import { ExecOptions } from 'node:child_process';
|
|
3
4
|
import * as decap_cms_core from 'decap-cms-core';
|
|
4
5
|
import { CmsEventListener, CMS, EditorComponentOptions, Formatter, CmsFieldMarkdown, CmsField, CmsFieldMeta, CmsCollectionFile, CmsConfig, CmsLocalBackend, CmsBackend, CmsFieldStringOrText, CmsFieldBase, CmsCollection } from 'decap-cms-core';
|
|
5
|
-
import { ExecOptions } from 'child_process';
|
|
6
6
|
|
|
7
7
|
interface CmsHookContext {
|
|
8
8
|
app: CMS;
|
|
@@ -83,13 +83,14 @@ type ScriptOptions = {
|
|
|
83
83
|
|
|
84
84
|
type CamelToSnakeCase<S extends string, I extends string = never> = S extends `${infer T}${infer U}` ? S extends I ? S : `${T extends Capitalize<T> ? '_' : ''}${Lowercase<T>}${CamelToSnakeCase<U>}` : S;
|
|
85
85
|
type KeysToSnakeCase<T> = {
|
|
86
|
-
[K in keyof T as CamelToSnakeCase<string & K, 'i18n'>]: T[K];
|
|
86
|
+
[K in keyof T as CamelToSnakeCase<string & K, 'i18n'>]: T[K] extends boolean ? T[K] : T[K] extends {} ? T[K] extends unknown[] ? KeysToSnakeCase<T[K][number]>[] : KeysToSnakeCase<T[K]> : T[K];
|
|
87
87
|
};
|
|
88
88
|
type CamelCase<S extends string> = S extends `${infer P1}_${infer P2}${infer P3}` ? `${Lowercase<P1>}${Uppercase<P2>}${CamelCase<P3>}` : Lowercase<S>;
|
|
89
89
|
type KeysToCamelCase<T> = {
|
|
90
|
-
[K in keyof T as CamelCase<string & K>]: T[K] extends {} ? KeysToCamelCase<T[K]> : T[K];
|
|
90
|
+
[K in keyof T as CamelCase<string & K>]: T[K] extends boolean ? T[K] : T[K] extends {} ? T[K] extends unknown[] ? KeysToCamelCase<T[K][number]>[] : KeysToCamelCase<T[K]> : T[K];
|
|
91
91
|
};
|
|
92
92
|
type PickRequired<O extends object, K extends keyof O> = Omit<O, K> & Required<Pick<O, K>>;
|
|
93
|
+
|
|
93
94
|
type EnvContextOption = boolean | 'dev' | 'prod';
|
|
94
95
|
type EnvDevContextOption = Exclude<EnvContextOption, 'prod'>;
|
|
95
96
|
type CollectionType = 'file' | 'folder';
|
|
@@ -99,11 +100,11 @@ type DecapCmsFieldType = NonNullable<Exclude<CmsField, CmsFieldMeta>['widget']>;
|
|
|
99
100
|
type DecapCmsWidget = Exclude<CmsField, CmsFieldStringOrText | CmsFieldMeta> | (CmsFieldBase & PickRequired<CmsFieldStringOrText, 'widget'>);
|
|
100
101
|
type DecapCmsFieldWidget<Name extends DecapCmsFieldType> = DecapCmsWidget extends infer K ? K extends DecapCmsWidget ? Name extends K['widget'] ? K : never : never : never;
|
|
101
102
|
type DecapCmsCollectionFile = KeysToCamelCase<Omit<CmsCollectionFile, 'fields'>> & {
|
|
102
|
-
fields: DecapCmsField[];
|
|
103
|
+
fields: DecapCmsField[] | CmsField[];
|
|
103
104
|
};
|
|
104
105
|
type BaseDecapCmsCollection<Props> = KeysToCamelCase<Omit<CmsCollection, 'files' | 'fields'>> & Props;
|
|
105
106
|
type DecapCmsCollection<Type extends CollectionType = CollectionType> = Type extends 'folder' ? BaseDecapCmsCollection<{
|
|
106
|
-
fields: DecapCmsField[];
|
|
107
|
+
fields: DecapCmsField[] | CmsField[];
|
|
107
108
|
}> : Type extends 'file' ? BaseDecapCmsCollection<{
|
|
108
109
|
files: DecapCmsCollectionFile[];
|
|
109
110
|
}> : never;
|
|
@@ -182,6 +183,26 @@ interface DecapProxyOptions {
|
|
|
182
183
|
* @default 8081
|
|
183
184
|
*/
|
|
184
185
|
port?: number;
|
|
186
|
+
/**
|
|
187
|
+
* Undocumented.
|
|
188
|
+
*
|
|
189
|
+
* Option for the process environment variable 'MODE'.
|
|
190
|
+
* @default 'fs'
|
|
191
|
+
*/
|
|
192
|
+
mode?: 'git' | 'fs';
|
|
193
|
+
/**
|
|
194
|
+
* Option for the process environment variable 'GIT_REPO_DIRECTORY'.
|
|
195
|
+
*
|
|
196
|
+
* The full local path to the git repo
|
|
197
|
+
* @default 'process.cwd()'
|
|
198
|
+
*/
|
|
199
|
+
gitRepoDirectory?: string;
|
|
200
|
+
/**
|
|
201
|
+
* Option for the process environment variable 'LOG_LEVEL'.
|
|
202
|
+
*
|
|
203
|
+
* @default 'info'
|
|
204
|
+
*/
|
|
205
|
+
logLevel?: string;
|
|
185
206
|
/**
|
|
186
207
|
* Pass any option to use in the child process
|
|
187
208
|
* @default undefined
|
|
@@ -231,18 +252,6 @@ interface Options {
|
|
|
231
252
|
};
|
|
232
253
|
}
|
|
233
254
|
|
|
234
|
-
declare function getGitData(): {
|
|
235
|
-
getBranch(): string | undefined;
|
|
236
|
-
getCommitSha(): string | undefined;
|
|
237
|
-
};
|
|
238
|
-
declare function createField<T extends DecapCmsFieldType>(widget: T, data: Omit<DecapCmsFieldWidget<T>, 'widget'>): DecapCmsFieldWidget<T>;
|
|
239
|
-
declare function createFolderCollection(data: DecapCmsCollection<'folder'>): KeysToCamelCase<Omit<decap_cms_core.CmsCollection, "fields" | "files">> & {
|
|
240
|
-
fields: DecapCmsField[];
|
|
241
|
-
};
|
|
242
|
-
declare function createFile(data: DecapCmsCollectionFile): DecapCmsCollectionFile;
|
|
243
|
-
declare function createFileCollection(data: DecapCmsCollection<'file'>): KeysToCamelCase<Omit<decap_cms_core.CmsCollection, "fields" | "files">> & {
|
|
244
|
-
files: DecapCmsCollectionFile[];
|
|
245
|
-
};
|
|
246
255
|
type OverwriteOptions = Omit<CmsFieldBase, 'name'> & {
|
|
247
256
|
/**
|
|
248
257
|
* Hide this field in the CMS editor UI.
|
|
@@ -255,12 +264,15 @@ type OverwriteOptions = Omit<CmsFieldBase, 'name'> & {
|
|
|
255
264
|
*/
|
|
256
265
|
deleted?: boolean;
|
|
257
266
|
};
|
|
267
|
+
declare function createOverwriteableField<T extends DecapCmsFieldType>(widget: T, data: Omit<DecapCmsFieldWidget<T>, 'widget'>, overwrites?: OverwriteOptions): DecapCmsFieldWidget<T> | DecapCmsFieldWidget<'hidden'> | undefined;
|
|
268
|
+
|
|
258
269
|
type VitePressPageFrontmatterKeys = 'title' | 'titleTemplate' | 'description' | 'head' | 'body';
|
|
259
270
|
interface BaseVitePressFieldOptions<Keys extends string> {
|
|
260
|
-
overwrites?: Partial<Record<Keys, OverwriteOptions
|
|
271
|
+
overwrites?: Partial<Record<Keys, OverwriteOptions>> & Partial<OverwriteOptions>;
|
|
261
272
|
}
|
|
273
|
+
type VitePressAdditionalField = DecapCmsField | CmsField;
|
|
262
274
|
interface VitePressFieldOptions extends BaseVitePressFieldOptions<VitePressPageFrontmatterKeys> {
|
|
263
|
-
additionalFields?:
|
|
275
|
+
additionalFields?: VitePressAdditionalField[];
|
|
264
276
|
/**
|
|
265
277
|
* Options for the markdown editor in the CMS
|
|
266
278
|
*/
|
|
@@ -269,7 +281,7 @@ interface VitePressFieldOptions extends BaseVitePressFieldOptions<VitePressPageF
|
|
|
269
281
|
type VitePressDefaultThemeFrontmatterKeys = 'layout' | 'navbar' | 'sidebar' | 'aside' | 'outline' | 'lastUpdated' | 'editLink' | 'footer' | 'pageClass';
|
|
270
282
|
type VitePressDefaultThemeFieldOptions = BaseVitePressFieldOptions<VitePressDefaultThemeFrontmatterKeys>;
|
|
271
283
|
type VitePressHomePageFrontmatterKeys = 'hero' | 'heroName' | 'heroText' | 'heroTagline' | 'heroImage' | 'heroActions' | 'heroActionTheme' | 'heroActionText' | 'heroActionLink' | 'heroActionTarget' | 'heroActionRel' | 'features' | 'featuresTitle' | 'featuresDetails' | 'featuresIcon' | 'featuresLink' | 'featuresLinkText' | 'featuresRel' | 'featuresTarget';
|
|
272
|
-
type VitePressHomePageFieldOptions = BaseVitePressFieldOptions<VitePressHomePageFrontmatterKeys
|
|
284
|
+
type VitePressHomePageFieldOptions = BaseVitePressFieldOptions<VitePressHomePageFrontmatterKeys> & Partial<Record<'additionalHeroFields' | 'additionalHeroActionFields' | 'additionalFeatureFields', VitePressAdditionalField[]>>;
|
|
273
285
|
declare class VitePress {
|
|
274
286
|
/**
|
|
275
287
|
* Create fields for:
|
|
@@ -287,17 +299,18 @@ declare class VitePress {
|
|
|
287
299
|
* @param options Options for overwriting field data
|
|
288
300
|
* @see https://vitepress.dev/reference/frontmatter-config#default-theme-only
|
|
289
301
|
*/
|
|
290
|
-
static createDefaultThemeNormalPageFields(options?: VitePressDefaultThemeFieldOptions):
|
|
302
|
+
static createDefaultThemeNormalPageFields(options?: VitePressDefaultThemeFieldOptions): CmsField[];
|
|
291
303
|
/**
|
|
292
304
|
* Create fields for:
|
|
293
305
|
* - title
|
|
294
306
|
* - titleTemplate
|
|
295
307
|
* - description
|
|
296
308
|
* - head
|
|
309
|
+
* - body (field for writing the markdown in the file)
|
|
297
310
|
* @param options.overwrites Overwrite data, such as labels, for the fields
|
|
298
311
|
* @see https://vitepress.dev/reference/frontmatter-config
|
|
299
312
|
*/
|
|
300
|
-
static createDefaultPageFields(options?: VitePressFieldOptions):
|
|
313
|
+
static createDefaultPageFields(options?: VitePressFieldOptions): CmsField[];
|
|
301
314
|
/**
|
|
302
315
|
* Create fields for:
|
|
303
316
|
* - layout: home (not overwriteable)
|
|
@@ -306,7 +319,7 @@ declare class VitePress {
|
|
|
306
319
|
*
|
|
307
320
|
* The object fields (`features`, `hero`, `heroActions`) can not be hidden and deleted.
|
|
308
321
|
*/
|
|
309
|
-
static createHomePageFields(options?: VitePressHomePageFieldOptions):
|
|
322
|
+
static createHomePageFields(options?: VitePressHomePageFieldOptions): CmsField[];
|
|
310
323
|
static createDefaultPageFolderCollection(name: string, folder: string, options?: VitePressFieldOptions & {
|
|
311
324
|
collection?: Partial<Omit<DecapCmsCollection<'folder'>, 'name' | 'fields' | 'folder'>>;
|
|
312
325
|
}): DecapCmsCollection<'folder'>;
|
|
@@ -320,6 +333,46 @@ declare class VitePress {
|
|
|
320
333
|
};
|
|
321
334
|
}
|
|
322
335
|
|
|
336
|
+
declare function createField<T extends DecapCmsFieldType>(widget: T, data: Omit<DecapCmsFieldWidget<T>, 'widget'>): DecapCmsFieldWidget<T>;
|
|
337
|
+
declare function createFolderCollection(data: DecapCmsCollection<'folder'>): KeysToCamelCase<Omit<decap_cms_core.CmsCollection, "fields" | "files">> & {
|
|
338
|
+
fields: DecapCmsField[] | CmsField[];
|
|
339
|
+
};
|
|
340
|
+
declare function createFile(data: DecapCmsCollectionFile): DecapCmsCollectionFile;
|
|
341
|
+
declare function createFileCollection(data: DecapCmsCollection<'file'>): KeysToCamelCase<Omit<decap_cms_core.CmsCollection, "fields" | "files">> & {
|
|
342
|
+
files: DecapCmsCollectionFile[];
|
|
343
|
+
};
|
|
344
|
+
declare function fieldToSnakeCase(field: DecapCmsField | CmsField): CmsField;
|
|
345
|
+
type SharedAction<Type> = (Type extends (string | undefined) ? true : Type extends (unknown[] | undefined) ? true : false) extends true ? ({
|
|
346
|
+
/**
|
|
347
|
+
* The action to take when combining options from shared and collection options:
|
|
348
|
+
* - append: if specified in another collection, the new options will be appended to the shared value
|
|
349
|
+
* - overwrite: if specified in another collection, the new options will overwrite the share value
|
|
350
|
+
* @default 'overwrite'
|
|
351
|
+
*/
|
|
352
|
+
action?: 'append' | 'overwrite';
|
|
353
|
+
value: Type;
|
|
354
|
+
} | Type) : Type;
|
|
355
|
+
type PartialIf<If extends boolean, T> = If extends true ? Partial<T> : T;
|
|
356
|
+
type Invert<T extends boolean> = T extends true ? false : true;
|
|
357
|
+
type SharedDecapCmsCollection<Type extends CollectionType> = Omit<DecapCmsCollection<Type>, 'fields' | 'files'>;
|
|
358
|
+
type SharedDecapCmsCollectionOptions<Type extends CollectionType> = {
|
|
359
|
+
[K in keyof SharedDecapCmsCollection<Type>]: SharedAction<SharedDecapCmsCollection<Type>[K]>;
|
|
360
|
+
};
|
|
361
|
+
interface SharedOptions<Parent extends boolean = true> extends Pick<Exclude<SharedAction<string>, string>, 'action'> {
|
|
362
|
+
/**
|
|
363
|
+
* Changes the types on where required name fields (name, labels) must be defined:
|
|
364
|
+
* on the shared or collection options.
|
|
365
|
+
* @default true
|
|
366
|
+
*/
|
|
367
|
+
requiredNameOnChildOptions?: Parent;
|
|
368
|
+
}
|
|
369
|
+
declare function createSharedCollectionOptions<Type extends CollectionType = CollectionType, Parent extends boolean = true, ChildType extends CollectionType = Type>(shared: PartialIf<Parent, SharedDecapCmsCollectionOptions<Type>>, options?: SharedOptions<Parent>): (collection: PartialIf<Invert<Parent>, SharedDecapCmsCollection<ChildType>>) => SharedDecapCmsCollection<ChildType>;
|
|
370
|
+
|
|
371
|
+
declare function getGitData(): {
|
|
372
|
+
getBranch(): string | undefined;
|
|
373
|
+
getCommitSha(): string | undefined;
|
|
374
|
+
};
|
|
375
|
+
|
|
323
376
|
declare function VitePluginDecapCMS(options: Options): Plugin;
|
|
324
377
|
|
|
325
|
-
export { type CdnLinkOptions, type CollectionType, type DecapCmsCollection, type DecapCmsCollectionFile, type DecapCmsConfig, type DecapCmsField, type DecapCmsFieldType, type DecapCmsFieldWidget, type DecapCmsMarkdownFieldRenderOptions, type DecapProxyOptions, type EnvContextOption, type EnvDevContextOption, type HeadConfig, type KeysToCamelCase, type KeysToSnakeCase, type LoginPageOptions, type Options, type OverwriteOptions, VitePress, type VitePressDefaultThemeFieldOptions, type VitePressDefaultThemeFrontmatterKeys, type VitePressFieldOptions, type VitePressHomePageFieldOptions, type VitePressHomePageFrontmatterKeys, type VitePressPageFrontmatterKeys, createField, createFile, createFileCollection, createFolderCollection, VitePluginDecapCMS as default, getGitData };
|
|
378
|
+
export { type CdnLinkOptions, type CollectionType, type DecapCmsCollection, type DecapCmsCollectionFile, type DecapCmsConfig, type DecapCmsField, type DecapCmsFieldType, type DecapCmsFieldWidget, type DecapCmsMarkdownFieldRenderOptions, type DecapProxyOptions, type EnvContextOption, type EnvDevContextOption, type HeadConfig, type KeysToCamelCase, type KeysToSnakeCase, type LoginPageOptions, type Options, type OverwriteOptions, type SharedDecapCmsCollection, type SharedDecapCmsCollectionOptions, type SharedOptions, VitePress, type VitePressAdditionalField, type VitePressDefaultThemeFieldOptions, type VitePressDefaultThemeFrontmatterKeys, type VitePressFieldOptions, type VitePressHomePageFieldOptions, type VitePressHomePageFrontmatterKeys, type VitePressPageFrontmatterKeys, createField, createFile, createFileCollection, createFolderCollection, createOverwriteableField, createSharedCollectionOptions, VitePluginDecapCMS as default, fieldToSnakeCase, getGitData };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
2
|
import * as yaml from 'yaml';
|
|
3
|
+
import { ExecOptions } from 'node:child_process';
|
|
3
4
|
import * as decap_cms_core from 'decap-cms-core';
|
|
4
5
|
import { CmsEventListener, CMS, EditorComponentOptions, Formatter, CmsFieldMarkdown, CmsField, CmsFieldMeta, CmsCollectionFile, CmsConfig, CmsLocalBackend, CmsBackend, CmsFieldStringOrText, CmsFieldBase, CmsCollection } from 'decap-cms-core';
|
|
5
|
-
import { ExecOptions } from 'child_process';
|
|
6
6
|
|
|
7
7
|
interface CmsHookContext {
|
|
8
8
|
app: CMS;
|
|
@@ -83,13 +83,14 @@ type ScriptOptions = {
|
|
|
83
83
|
|
|
84
84
|
type CamelToSnakeCase<S extends string, I extends string = never> = S extends `${infer T}${infer U}` ? S extends I ? S : `${T extends Capitalize<T> ? '_' : ''}${Lowercase<T>}${CamelToSnakeCase<U>}` : S;
|
|
85
85
|
type KeysToSnakeCase<T> = {
|
|
86
|
-
[K in keyof T as CamelToSnakeCase<string & K, 'i18n'>]: T[K];
|
|
86
|
+
[K in keyof T as CamelToSnakeCase<string & K, 'i18n'>]: T[K] extends boolean ? T[K] : T[K] extends {} ? T[K] extends unknown[] ? KeysToSnakeCase<T[K][number]>[] : KeysToSnakeCase<T[K]> : T[K];
|
|
87
87
|
};
|
|
88
88
|
type CamelCase<S extends string> = S extends `${infer P1}_${infer P2}${infer P3}` ? `${Lowercase<P1>}${Uppercase<P2>}${CamelCase<P3>}` : Lowercase<S>;
|
|
89
89
|
type KeysToCamelCase<T> = {
|
|
90
|
-
[K in keyof T as CamelCase<string & K>]: T[K] extends {} ? KeysToCamelCase<T[K]> : T[K];
|
|
90
|
+
[K in keyof T as CamelCase<string & K>]: T[K] extends boolean ? T[K] : T[K] extends {} ? T[K] extends unknown[] ? KeysToCamelCase<T[K][number]>[] : KeysToCamelCase<T[K]> : T[K];
|
|
91
91
|
};
|
|
92
92
|
type PickRequired<O extends object, K extends keyof O> = Omit<O, K> & Required<Pick<O, K>>;
|
|
93
|
+
|
|
93
94
|
type EnvContextOption = boolean | 'dev' | 'prod';
|
|
94
95
|
type EnvDevContextOption = Exclude<EnvContextOption, 'prod'>;
|
|
95
96
|
type CollectionType = 'file' | 'folder';
|
|
@@ -99,11 +100,11 @@ type DecapCmsFieldType = NonNullable<Exclude<CmsField, CmsFieldMeta>['widget']>;
|
|
|
99
100
|
type DecapCmsWidget = Exclude<CmsField, CmsFieldStringOrText | CmsFieldMeta> | (CmsFieldBase & PickRequired<CmsFieldStringOrText, 'widget'>);
|
|
100
101
|
type DecapCmsFieldWidget<Name extends DecapCmsFieldType> = DecapCmsWidget extends infer K ? K extends DecapCmsWidget ? Name extends K['widget'] ? K : never : never : never;
|
|
101
102
|
type DecapCmsCollectionFile = KeysToCamelCase<Omit<CmsCollectionFile, 'fields'>> & {
|
|
102
|
-
fields: DecapCmsField[];
|
|
103
|
+
fields: DecapCmsField[] | CmsField[];
|
|
103
104
|
};
|
|
104
105
|
type BaseDecapCmsCollection<Props> = KeysToCamelCase<Omit<CmsCollection, 'files' | 'fields'>> & Props;
|
|
105
106
|
type DecapCmsCollection<Type extends CollectionType = CollectionType> = Type extends 'folder' ? BaseDecapCmsCollection<{
|
|
106
|
-
fields: DecapCmsField[];
|
|
107
|
+
fields: DecapCmsField[] | CmsField[];
|
|
107
108
|
}> : Type extends 'file' ? BaseDecapCmsCollection<{
|
|
108
109
|
files: DecapCmsCollectionFile[];
|
|
109
110
|
}> : never;
|
|
@@ -182,6 +183,26 @@ interface DecapProxyOptions {
|
|
|
182
183
|
* @default 8081
|
|
183
184
|
*/
|
|
184
185
|
port?: number;
|
|
186
|
+
/**
|
|
187
|
+
* Undocumented.
|
|
188
|
+
*
|
|
189
|
+
* Option for the process environment variable 'MODE'.
|
|
190
|
+
* @default 'fs'
|
|
191
|
+
*/
|
|
192
|
+
mode?: 'git' | 'fs';
|
|
193
|
+
/**
|
|
194
|
+
* Option for the process environment variable 'GIT_REPO_DIRECTORY'.
|
|
195
|
+
*
|
|
196
|
+
* The full local path to the git repo
|
|
197
|
+
* @default 'process.cwd()'
|
|
198
|
+
*/
|
|
199
|
+
gitRepoDirectory?: string;
|
|
200
|
+
/**
|
|
201
|
+
* Option for the process environment variable 'LOG_LEVEL'.
|
|
202
|
+
*
|
|
203
|
+
* @default 'info'
|
|
204
|
+
*/
|
|
205
|
+
logLevel?: string;
|
|
185
206
|
/**
|
|
186
207
|
* Pass any option to use in the child process
|
|
187
208
|
* @default undefined
|
|
@@ -231,18 +252,6 @@ interface Options {
|
|
|
231
252
|
};
|
|
232
253
|
}
|
|
233
254
|
|
|
234
|
-
declare function getGitData(): {
|
|
235
|
-
getBranch(): string | undefined;
|
|
236
|
-
getCommitSha(): string | undefined;
|
|
237
|
-
};
|
|
238
|
-
declare function createField<T extends DecapCmsFieldType>(widget: T, data: Omit<DecapCmsFieldWidget<T>, 'widget'>): DecapCmsFieldWidget<T>;
|
|
239
|
-
declare function createFolderCollection(data: DecapCmsCollection<'folder'>): KeysToCamelCase<Omit<decap_cms_core.CmsCollection, "fields" | "files">> & {
|
|
240
|
-
fields: DecapCmsField[];
|
|
241
|
-
};
|
|
242
|
-
declare function createFile(data: DecapCmsCollectionFile): DecapCmsCollectionFile;
|
|
243
|
-
declare function createFileCollection(data: DecapCmsCollection<'file'>): KeysToCamelCase<Omit<decap_cms_core.CmsCollection, "fields" | "files">> & {
|
|
244
|
-
files: DecapCmsCollectionFile[];
|
|
245
|
-
};
|
|
246
255
|
type OverwriteOptions = Omit<CmsFieldBase, 'name'> & {
|
|
247
256
|
/**
|
|
248
257
|
* Hide this field in the CMS editor UI.
|
|
@@ -255,12 +264,15 @@ type OverwriteOptions = Omit<CmsFieldBase, 'name'> & {
|
|
|
255
264
|
*/
|
|
256
265
|
deleted?: boolean;
|
|
257
266
|
};
|
|
267
|
+
declare function createOverwriteableField<T extends DecapCmsFieldType>(widget: T, data: Omit<DecapCmsFieldWidget<T>, 'widget'>, overwrites?: OverwriteOptions): DecapCmsFieldWidget<T> | DecapCmsFieldWidget<'hidden'> | undefined;
|
|
268
|
+
|
|
258
269
|
type VitePressPageFrontmatterKeys = 'title' | 'titleTemplate' | 'description' | 'head' | 'body';
|
|
259
270
|
interface BaseVitePressFieldOptions<Keys extends string> {
|
|
260
|
-
overwrites?: Partial<Record<Keys, OverwriteOptions
|
|
271
|
+
overwrites?: Partial<Record<Keys, OverwriteOptions>> & Partial<OverwriteOptions>;
|
|
261
272
|
}
|
|
273
|
+
type VitePressAdditionalField = DecapCmsField | CmsField;
|
|
262
274
|
interface VitePressFieldOptions extends BaseVitePressFieldOptions<VitePressPageFrontmatterKeys> {
|
|
263
|
-
additionalFields?:
|
|
275
|
+
additionalFields?: VitePressAdditionalField[];
|
|
264
276
|
/**
|
|
265
277
|
* Options for the markdown editor in the CMS
|
|
266
278
|
*/
|
|
@@ -269,7 +281,7 @@ interface VitePressFieldOptions extends BaseVitePressFieldOptions<VitePressPageF
|
|
|
269
281
|
type VitePressDefaultThemeFrontmatterKeys = 'layout' | 'navbar' | 'sidebar' | 'aside' | 'outline' | 'lastUpdated' | 'editLink' | 'footer' | 'pageClass';
|
|
270
282
|
type VitePressDefaultThemeFieldOptions = BaseVitePressFieldOptions<VitePressDefaultThemeFrontmatterKeys>;
|
|
271
283
|
type VitePressHomePageFrontmatterKeys = 'hero' | 'heroName' | 'heroText' | 'heroTagline' | 'heroImage' | 'heroActions' | 'heroActionTheme' | 'heroActionText' | 'heroActionLink' | 'heroActionTarget' | 'heroActionRel' | 'features' | 'featuresTitle' | 'featuresDetails' | 'featuresIcon' | 'featuresLink' | 'featuresLinkText' | 'featuresRel' | 'featuresTarget';
|
|
272
|
-
type VitePressHomePageFieldOptions = BaseVitePressFieldOptions<VitePressHomePageFrontmatterKeys
|
|
284
|
+
type VitePressHomePageFieldOptions = BaseVitePressFieldOptions<VitePressHomePageFrontmatterKeys> & Partial<Record<'additionalHeroFields' | 'additionalHeroActionFields' | 'additionalFeatureFields', VitePressAdditionalField[]>>;
|
|
273
285
|
declare class VitePress {
|
|
274
286
|
/**
|
|
275
287
|
* Create fields for:
|
|
@@ -287,17 +299,18 @@ declare class VitePress {
|
|
|
287
299
|
* @param options Options for overwriting field data
|
|
288
300
|
* @see https://vitepress.dev/reference/frontmatter-config#default-theme-only
|
|
289
301
|
*/
|
|
290
|
-
static createDefaultThemeNormalPageFields(options?: VitePressDefaultThemeFieldOptions):
|
|
302
|
+
static createDefaultThemeNormalPageFields(options?: VitePressDefaultThemeFieldOptions): CmsField[];
|
|
291
303
|
/**
|
|
292
304
|
* Create fields for:
|
|
293
305
|
* - title
|
|
294
306
|
* - titleTemplate
|
|
295
307
|
* - description
|
|
296
308
|
* - head
|
|
309
|
+
* - body (field for writing the markdown in the file)
|
|
297
310
|
* @param options.overwrites Overwrite data, such as labels, for the fields
|
|
298
311
|
* @see https://vitepress.dev/reference/frontmatter-config
|
|
299
312
|
*/
|
|
300
|
-
static createDefaultPageFields(options?: VitePressFieldOptions):
|
|
313
|
+
static createDefaultPageFields(options?: VitePressFieldOptions): CmsField[];
|
|
301
314
|
/**
|
|
302
315
|
* Create fields for:
|
|
303
316
|
* - layout: home (not overwriteable)
|
|
@@ -306,7 +319,7 @@ declare class VitePress {
|
|
|
306
319
|
*
|
|
307
320
|
* The object fields (`features`, `hero`, `heroActions`) can not be hidden and deleted.
|
|
308
321
|
*/
|
|
309
|
-
static createHomePageFields(options?: VitePressHomePageFieldOptions):
|
|
322
|
+
static createHomePageFields(options?: VitePressHomePageFieldOptions): CmsField[];
|
|
310
323
|
static createDefaultPageFolderCollection(name: string, folder: string, options?: VitePressFieldOptions & {
|
|
311
324
|
collection?: Partial<Omit<DecapCmsCollection<'folder'>, 'name' | 'fields' | 'folder'>>;
|
|
312
325
|
}): DecapCmsCollection<'folder'>;
|
|
@@ -320,6 +333,46 @@ declare class VitePress {
|
|
|
320
333
|
};
|
|
321
334
|
}
|
|
322
335
|
|
|
336
|
+
declare function createField<T extends DecapCmsFieldType>(widget: T, data: Omit<DecapCmsFieldWidget<T>, 'widget'>): DecapCmsFieldWidget<T>;
|
|
337
|
+
declare function createFolderCollection(data: DecapCmsCollection<'folder'>): KeysToCamelCase<Omit<decap_cms_core.CmsCollection, "fields" | "files">> & {
|
|
338
|
+
fields: DecapCmsField[] | CmsField[];
|
|
339
|
+
};
|
|
340
|
+
declare function createFile(data: DecapCmsCollectionFile): DecapCmsCollectionFile;
|
|
341
|
+
declare function createFileCollection(data: DecapCmsCollection<'file'>): KeysToCamelCase<Omit<decap_cms_core.CmsCollection, "fields" | "files">> & {
|
|
342
|
+
files: DecapCmsCollectionFile[];
|
|
343
|
+
};
|
|
344
|
+
declare function fieldToSnakeCase(field: DecapCmsField | CmsField): CmsField;
|
|
345
|
+
type SharedAction<Type> = (Type extends (string | undefined) ? true : Type extends (unknown[] | undefined) ? true : false) extends true ? ({
|
|
346
|
+
/**
|
|
347
|
+
* The action to take when combining options from shared and collection options:
|
|
348
|
+
* - append: if specified in another collection, the new options will be appended to the shared value
|
|
349
|
+
* - overwrite: if specified in another collection, the new options will overwrite the share value
|
|
350
|
+
* @default 'overwrite'
|
|
351
|
+
*/
|
|
352
|
+
action?: 'append' | 'overwrite';
|
|
353
|
+
value: Type;
|
|
354
|
+
} | Type) : Type;
|
|
355
|
+
type PartialIf<If extends boolean, T> = If extends true ? Partial<T> : T;
|
|
356
|
+
type Invert<T extends boolean> = T extends true ? false : true;
|
|
357
|
+
type SharedDecapCmsCollection<Type extends CollectionType> = Omit<DecapCmsCollection<Type>, 'fields' | 'files'>;
|
|
358
|
+
type SharedDecapCmsCollectionOptions<Type extends CollectionType> = {
|
|
359
|
+
[K in keyof SharedDecapCmsCollection<Type>]: SharedAction<SharedDecapCmsCollection<Type>[K]>;
|
|
360
|
+
};
|
|
361
|
+
interface SharedOptions<Parent extends boolean = true> extends Pick<Exclude<SharedAction<string>, string>, 'action'> {
|
|
362
|
+
/**
|
|
363
|
+
* Changes the types on where required name fields (name, labels) must be defined:
|
|
364
|
+
* on the shared or collection options.
|
|
365
|
+
* @default true
|
|
366
|
+
*/
|
|
367
|
+
requiredNameOnChildOptions?: Parent;
|
|
368
|
+
}
|
|
369
|
+
declare function createSharedCollectionOptions<Type extends CollectionType = CollectionType, Parent extends boolean = true, ChildType extends CollectionType = Type>(shared: PartialIf<Parent, SharedDecapCmsCollectionOptions<Type>>, options?: SharedOptions<Parent>): (collection: PartialIf<Invert<Parent>, SharedDecapCmsCollection<ChildType>>) => SharedDecapCmsCollection<ChildType>;
|
|
370
|
+
|
|
371
|
+
declare function getGitData(): {
|
|
372
|
+
getBranch(): string | undefined;
|
|
373
|
+
getCommitSha(): string | undefined;
|
|
374
|
+
};
|
|
375
|
+
|
|
323
376
|
declare function VitePluginDecapCMS(options: Options): Plugin;
|
|
324
377
|
|
|
325
|
-
export { type CdnLinkOptions, type CollectionType, type DecapCmsCollection, type DecapCmsCollectionFile, type DecapCmsConfig, type DecapCmsField, type DecapCmsFieldType, type DecapCmsFieldWidget, type DecapCmsMarkdownFieldRenderOptions, type DecapProxyOptions, type EnvContextOption, type EnvDevContextOption, type HeadConfig, type KeysToCamelCase, type KeysToSnakeCase, type LoginPageOptions, type Options, type OverwriteOptions, VitePress, type VitePressDefaultThemeFieldOptions, type VitePressDefaultThemeFrontmatterKeys, type VitePressFieldOptions, type VitePressHomePageFieldOptions, type VitePressHomePageFrontmatterKeys, type VitePressPageFrontmatterKeys, createField, createFile, createFileCollection, createFolderCollection, VitePluginDecapCMS as default, getGitData };
|
|
378
|
+
export { type CdnLinkOptions, type CollectionType, type DecapCmsCollection, type DecapCmsCollectionFile, type DecapCmsConfig, type DecapCmsField, type DecapCmsFieldType, type DecapCmsFieldWidget, type DecapCmsMarkdownFieldRenderOptions, type DecapProxyOptions, type EnvContextOption, type EnvDevContextOption, type HeadConfig, type KeysToCamelCase, type KeysToSnakeCase, type LoginPageOptions, type Options, type OverwriteOptions, type SharedDecapCmsCollection, type SharedDecapCmsCollectionOptions, type SharedOptions, VitePress, type VitePressAdditionalField, type VitePressDefaultThemeFieldOptions, type VitePressDefaultThemeFrontmatterKeys, type VitePressFieldOptions, type VitePressHomePageFieldOptions, type VitePressHomePageFrontmatterKeys, type VitePressPageFrontmatterKeys, createField, createFile, createFileCollection, createFolderCollection, createOverwriteableField, createSharedCollectionOptions, VitePluginDecapCMS as default, fieldToSnakeCase, getGitData };
|