vite-plugin-decap-cms 0.4.0 → 0.5.1
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 +70 -70
- package/dist/index.cjs +113 -179
- package/dist/index.d.cts +23 -74
- package/dist/index.d.ts +23 -74
- package/dist/index.js +109 -171
- package/package.json +54 -56
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';
|
|
4
3
|
import * as decap_cms_core from 'decap-cms-core';
|
|
5
4
|
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,14 +83,13 @@ 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];
|
|
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
|
|
90
|
+
[K in keyof T as CamelCase<string & K>]: T[K] extends {} ? 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
|
-
|
|
94
93
|
type EnvContextOption = boolean | 'dev' | 'prod';
|
|
95
94
|
type EnvDevContextOption = Exclude<EnvContextOption, 'prod'>;
|
|
96
95
|
type CollectionType = 'file' | 'folder';
|
|
@@ -100,11 +99,11 @@ type DecapCmsFieldType = NonNullable<Exclude<CmsField, CmsFieldMeta>['widget']>;
|
|
|
100
99
|
type DecapCmsWidget = Exclude<CmsField, CmsFieldStringOrText | CmsFieldMeta> | (CmsFieldBase & PickRequired<CmsFieldStringOrText, 'widget'>);
|
|
101
100
|
type DecapCmsFieldWidget<Name extends DecapCmsFieldType> = DecapCmsWidget extends infer K ? K extends DecapCmsWidget ? Name extends K['widget'] ? K : never : never : never;
|
|
102
101
|
type DecapCmsCollectionFile = KeysToCamelCase<Omit<CmsCollectionFile, 'fields'>> & {
|
|
103
|
-
fields: DecapCmsField[]
|
|
102
|
+
fields: DecapCmsField[];
|
|
104
103
|
};
|
|
105
104
|
type BaseDecapCmsCollection<Props> = KeysToCamelCase<Omit<CmsCollection, 'files' | 'fields'>> & Props;
|
|
106
105
|
type DecapCmsCollection<Type extends CollectionType = CollectionType> = Type extends 'folder' ? BaseDecapCmsCollection<{
|
|
107
|
-
fields: DecapCmsField[]
|
|
106
|
+
fields: DecapCmsField[];
|
|
108
107
|
}> : Type extends 'file' ? BaseDecapCmsCollection<{
|
|
109
108
|
files: DecapCmsCollectionFile[];
|
|
110
109
|
}> : never;
|
|
@@ -183,26 +182,6 @@ interface DecapProxyOptions {
|
|
|
183
182
|
* @default 8081
|
|
184
183
|
*/
|
|
185
184
|
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;
|
|
206
185
|
/**
|
|
207
186
|
* Pass any option to use in the child process
|
|
208
187
|
* @default undefined
|
|
@@ -252,6 +231,18 @@ interface Options {
|
|
|
252
231
|
};
|
|
253
232
|
}
|
|
254
233
|
|
|
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
|
+
};
|
|
255
246
|
type OverwriteOptions = Omit<CmsFieldBase, 'name'> & {
|
|
256
247
|
/**
|
|
257
248
|
* Hide this field in the CMS editor UI.
|
|
@@ -270,9 +261,8 @@ type VitePressPageFrontmatterKeys = 'title' | 'titleTemplate' | 'description' |
|
|
|
270
261
|
interface BaseVitePressFieldOptions<Keys extends string> {
|
|
271
262
|
overwrites?: Partial<Record<Keys, OverwriteOptions>> & Partial<OverwriteOptions>;
|
|
272
263
|
}
|
|
273
|
-
type VitePressAdditionalField = DecapCmsField | CmsField;
|
|
274
264
|
interface VitePressFieldOptions extends BaseVitePressFieldOptions<VitePressPageFrontmatterKeys> {
|
|
275
|
-
additionalFields?:
|
|
265
|
+
additionalFields?: DecapCmsField[];
|
|
276
266
|
/**
|
|
277
267
|
* Options for the markdown editor in the CMS
|
|
278
268
|
*/
|
|
@@ -281,7 +271,7 @@ interface VitePressFieldOptions extends BaseVitePressFieldOptions<VitePressPageF
|
|
|
281
271
|
type VitePressDefaultThemeFrontmatterKeys = 'layout' | 'navbar' | 'sidebar' | 'aside' | 'outline' | 'lastUpdated' | 'editLink' | 'footer' | 'pageClass';
|
|
282
272
|
type VitePressDefaultThemeFieldOptions = BaseVitePressFieldOptions<VitePressDefaultThemeFrontmatterKeys>;
|
|
283
273
|
type VitePressHomePageFrontmatterKeys = 'hero' | 'heroName' | 'heroText' | 'heroTagline' | 'heroImage' | 'heroActions' | 'heroActionTheme' | 'heroActionText' | 'heroActionLink' | 'heroActionTarget' | 'heroActionRel' | 'features' | 'featuresTitle' | 'featuresDetails' | 'featuresIcon' | 'featuresLink' | 'featuresLinkText' | 'featuresRel' | 'featuresTarget';
|
|
284
|
-
type VitePressHomePageFieldOptions = BaseVitePressFieldOptions<VitePressHomePageFrontmatterKeys> & Partial<Record<'additionalHeroFields' | 'additionalHeroActionFields' | 'additionalFeatureFields',
|
|
274
|
+
type VitePressHomePageFieldOptions = BaseVitePressFieldOptions<VitePressHomePageFrontmatterKeys> & Partial<Record<'additionalHeroFields' | 'additionalHeroActionFields' | 'additionalFeatureFields', DecapCmsField[]>>;
|
|
285
275
|
declare class VitePress {
|
|
286
276
|
/**
|
|
287
277
|
* Create fields for:
|
|
@@ -299,18 +289,17 @@ declare class VitePress {
|
|
|
299
289
|
* @param options Options for overwriting field data
|
|
300
290
|
* @see https://vitepress.dev/reference/frontmatter-config#default-theme-only
|
|
301
291
|
*/
|
|
302
|
-
static createDefaultThemeNormalPageFields(options?: VitePressDefaultThemeFieldOptions):
|
|
292
|
+
static createDefaultThemeNormalPageFields(options?: VitePressDefaultThemeFieldOptions): DecapCmsField[];
|
|
303
293
|
/**
|
|
304
294
|
* Create fields for:
|
|
305
295
|
* - title
|
|
306
296
|
* - titleTemplate
|
|
307
297
|
* - description
|
|
308
298
|
* - head
|
|
309
|
-
* - body (field for writing the markdown in the file)
|
|
310
299
|
* @param options.overwrites Overwrite data, such as labels, for the fields
|
|
311
300
|
* @see https://vitepress.dev/reference/frontmatter-config
|
|
312
301
|
*/
|
|
313
|
-
static createDefaultPageFields(options?: VitePressFieldOptions):
|
|
302
|
+
static createDefaultPageFields(options?: VitePressFieldOptions): DecapCmsField[];
|
|
314
303
|
/**
|
|
315
304
|
* Create fields for:
|
|
316
305
|
* - layout: home (not overwriteable)
|
|
@@ -319,7 +308,7 @@ declare class VitePress {
|
|
|
319
308
|
*
|
|
320
309
|
* The object fields (`features`, `hero`, `heroActions`) can not be hidden and deleted.
|
|
321
310
|
*/
|
|
322
|
-
static createHomePageFields(options?: VitePressHomePageFieldOptions):
|
|
311
|
+
static createHomePageFields(options?: VitePressHomePageFieldOptions): ((decap_cms_core.CmsFieldBase & decap_cms_core.CmsFieldList) | (decap_cms_core.CmsFieldBase & decap_cms_core.CmsFieldHidden) | undefined)[];
|
|
323
312
|
static createDefaultPageFolderCollection(name: string, folder: string, options?: VitePressFieldOptions & {
|
|
324
313
|
collection?: Partial<Omit<DecapCmsCollection<'folder'>, 'name' | 'fields' | 'folder'>>;
|
|
325
314
|
}): DecapCmsCollection<'folder'>;
|
|
@@ -333,46 +322,6 @@ declare class VitePress {
|
|
|
333
322
|
};
|
|
334
323
|
}
|
|
335
324
|
|
|
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
|
-
|
|
376
325
|
declare function VitePluginDecapCMS(options: Options): Plugin;
|
|
377
326
|
|
|
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,
|
|
327
|
+
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, createOverwriteableField, VitePluginDecapCMS as default, 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';
|
|
4
3
|
import * as decap_cms_core from 'decap-cms-core';
|
|
5
4
|
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,14 +83,13 @@ 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];
|
|
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
|
|
90
|
+
[K in keyof T as CamelCase<string & K>]: T[K] extends {} ? 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
|
-
|
|
94
93
|
type EnvContextOption = boolean | 'dev' | 'prod';
|
|
95
94
|
type EnvDevContextOption = Exclude<EnvContextOption, 'prod'>;
|
|
96
95
|
type CollectionType = 'file' | 'folder';
|
|
@@ -100,11 +99,11 @@ type DecapCmsFieldType = NonNullable<Exclude<CmsField, CmsFieldMeta>['widget']>;
|
|
|
100
99
|
type DecapCmsWidget = Exclude<CmsField, CmsFieldStringOrText | CmsFieldMeta> | (CmsFieldBase & PickRequired<CmsFieldStringOrText, 'widget'>);
|
|
101
100
|
type DecapCmsFieldWidget<Name extends DecapCmsFieldType> = DecapCmsWidget extends infer K ? K extends DecapCmsWidget ? Name extends K['widget'] ? K : never : never : never;
|
|
102
101
|
type DecapCmsCollectionFile = KeysToCamelCase<Omit<CmsCollectionFile, 'fields'>> & {
|
|
103
|
-
fields: DecapCmsField[]
|
|
102
|
+
fields: DecapCmsField[];
|
|
104
103
|
};
|
|
105
104
|
type BaseDecapCmsCollection<Props> = KeysToCamelCase<Omit<CmsCollection, 'files' | 'fields'>> & Props;
|
|
106
105
|
type DecapCmsCollection<Type extends CollectionType = CollectionType> = Type extends 'folder' ? BaseDecapCmsCollection<{
|
|
107
|
-
fields: DecapCmsField[]
|
|
106
|
+
fields: DecapCmsField[];
|
|
108
107
|
}> : Type extends 'file' ? BaseDecapCmsCollection<{
|
|
109
108
|
files: DecapCmsCollectionFile[];
|
|
110
109
|
}> : never;
|
|
@@ -183,26 +182,6 @@ interface DecapProxyOptions {
|
|
|
183
182
|
* @default 8081
|
|
184
183
|
*/
|
|
185
184
|
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;
|
|
206
185
|
/**
|
|
207
186
|
* Pass any option to use in the child process
|
|
208
187
|
* @default undefined
|
|
@@ -252,6 +231,18 @@ interface Options {
|
|
|
252
231
|
};
|
|
253
232
|
}
|
|
254
233
|
|
|
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
|
+
};
|
|
255
246
|
type OverwriteOptions = Omit<CmsFieldBase, 'name'> & {
|
|
256
247
|
/**
|
|
257
248
|
* Hide this field in the CMS editor UI.
|
|
@@ -270,9 +261,8 @@ type VitePressPageFrontmatterKeys = 'title' | 'titleTemplate' | 'description' |
|
|
|
270
261
|
interface BaseVitePressFieldOptions<Keys extends string> {
|
|
271
262
|
overwrites?: Partial<Record<Keys, OverwriteOptions>> & Partial<OverwriteOptions>;
|
|
272
263
|
}
|
|
273
|
-
type VitePressAdditionalField = DecapCmsField | CmsField;
|
|
274
264
|
interface VitePressFieldOptions extends BaseVitePressFieldOptions<VitePressPageFrontmatterKeys> {
|
|
275
|
-
additionalFields?:
|
|
265
|
+
additionalFields?: DecapCmsField[];
|
|
276
266
|
/**
|
|
277
267
|
* Options for the markdown editor in the CMS
|
|
278
268
|
*/
|
|
@@ -281,7 +271,7 @@ interface VitePressFieldOptions extends BaseVitePressFieldOptions<VitePressPageF
|
|
|
281
271
|
type VitePressDefaultThemeFrontmatterKeys = 'layout' | 'navbar' | 'sidebar' | 'aside' | 'outline' | 'lastUpdated' | 'editLink' | 'footer' | 'pageClass';
|
|
282
272
|
type VitePressDefaultThemeFieldOptions = BaseVitePressFieldOptions<VitePressDefaultThemeFrontmatterKeys>;
|
|
283
273
|
type VitePressHomePageFrontmatterKeys = 'hero' | 'heroName' | 'heroText' | 'heroTagline' | 'heroImage' | 'heroActions' | 'heroActionTheme' | 'heroActionText' | 'heroActionLink' | 'heroActionTarget' | 'heroActionRel' | 'features' | 'featuresTitle' | 'featuresDetails' | 'featuresIcon' | 'featuresLink' | 'featuresLinkText' | 'featuresRel' | 'featuresTarget';
|
|
284
|
-
type VitePressHomePageFieldOptions = BaseVitePressFieldOptions<VitePressHomePageFrontmatterKeys> & Partial<Record<'additionalHeroFields' | 'additionalHeroActionFields' | 'additionalFeatureFields',
|
|
274
|
+
type VitePressHomePageFieldOptions = BaseVitePressFieldOptions<VitePressHomePageFrontmatterKeys> & Partial<Record<'additionalHeroFields' | 'additionalHeroActionFields' | 'additionalFeatureFields', DecapCmsField[]>>;
|
|
285
275
|
declare class VitePress {
|
|
286
276
|
/**
|
|
287
277
|
* Create fields for:
|
|
@@ -299,18 +289,17 @@ declare class VitePress {
|
|
|
299
289
|
* @param options Options for overwriting field data
|
|
300
290
|
* @see https://vitepress.dev/reference/frontmatter-config#default-theme-only
|
|
301
291
|
*/
|
|
302
|
-
static createDefaultThemeNormalPageFields(options?: VitePressDefaultThemeFieldOptions):
|
|
292
|
+
static createDefaultThemeNormalPageFields(options?: VitePressDefaultThemeFieldOptions): DecapCmsField[];
|
|
303
293
|
/**
|
|
304
294
|
* Create fields for:
|
|
305
295
|
* - title
|
|
306
296
|
* - titleTemplate
|
|
307
297
|
* - description
|
|
308
298
|
* - head
|
|
309
|
-
* - body (field for writing the markdown in the file)
|
|
310
299
|
* @param options.overwrites Overwrite data, such as labels, for the fields
|
|
311
300
|
* @see https://vitepress.dev/reference/frontmatter-config
|
|
312
301
|
*/
|
|
313
|
-
static createDefaultPageFields(options?: VitePressFieldOptions):
|
|
302
|
+
static createDefaultPageFields(options?: VitePressFieldOptions): DecapCmsField[];
|
|
314
303
|
/**
|
|
315
304
|
* Create fields for:
|
|
316
305
|
* - layout: home (not overwriteable)
|
|
@@ -319,7 +308,7 @@ declare class VitePress {
|
|
|
319
308
|
*
|
|
320
309
|
* The object fields (`features`, `hero`, `heroActions`) can not be hidden and deleted.
|
|
321
310
|
*/
|
|
322
|
-
static createHomePageFields(options?: VitePressHomePageFieldOptions):
|
|
311
|
+
static createHomePageFields(options?: VitePressHomePageFieldOptions): ((decap_cms_core.CmsFieldBase & decap_cms_core.CmsFieldList) | (decap_cms_core.CmsFieldBase & decap_cms_core.CmsFieldHidden) | undefined)[];
|
|
323
312
|
static createDefaultPageFolderCollection(name: string, folder: string, options?: VitePressFieldOptions & {
|
|
324
313
|
collection?: Partial<Omit<DecapCmsCollection<'folder'>, 'name' | 'fields' | 'folder'>>;
|
|
325
314
|
}): DecapCmsCollection<'folder'>;
|
|
@@ -333,46 +322,6 @@ declare class VitePress {
|
|
|
333
322
|
};
|
|
334
323
|
}
|
|
335
324
|
|
|
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
|
-
|
|
376
325
|
declare function VitePluginDecapCMS(options: Options): Plugin;
|
|
377
326
|
|
|
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,
|
|
327
|
+
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, createOverwriteableField, VitePluginDecapCMS as default, getGitData };
|