vite-plugin-decap-cms 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +69 -0
- package/dist/index.cjs +446 -0
- package/dist/index.d.cts +248 -0
- package/dist/index.d.ts +248 -0
- package/dist/index.js +419 -0
- package/package.json +52 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import * as vite from 'vite';
|
|
2
|
+
import { Plugin } from 'vite';
|
|
3
|
+
import * as yaml from 'yaml';
|
|
4
|
+
import * as decap_cms_core from 'decap-cms-core';
|
|
5
|
+
import { CmsEventListener, CMS, CmsFieldMarkdown, CmsField, CmsFieldMeta, CmsCollectionFile, CmsConfig, CmsLocalBackend, CmsBackend, CmsFieldStringOrText, CmsFieldBase, CmsCollection } from 'decap-cms-core';
|
|
6
|
+
|
|
7
|
+
interface CmsHookContext {
|
|
8
|
+
app: CMS;
|
|
9
|
+
}
|
|
10
|
+
type CmsEventHookContext = CmsHookContext & Parameters<CmsEventListener['handler']>[0];
|
|
11
|
+
type ScriptOptions = {
|
|
12
|
+
[event in `on${Capitalize<CmsEventListener['name']>}`]?: (ctx: CmsEventHookContext) => Promise<void> | void;
|
|
13
|
+
} & {
|
|
14
|
+
/**
|
|
15
|
+
* Called when the admin UI is initialized.
|
|
16
|
+
* This hook is run in the browser.
|
|
17
|
+
* @param ctx
|
|
18
|
+
*/
|
|
19
|
+
onInitialized?(ctx: CmsHookContext): Promise<void> | void;
|
|
20
|
+
/**
|
|
21
|
+
* Called when the config is written in builds.
|
|
22
|
+
* This hook is run in Node.js.
|
|
23
|
+
*/
|
|
24
|
+
onGenerated?(): Promise<void> | void;
|
|
25
|
+
/**
|
|
26
|
+
* Called when the config is written.
|
|
27
|
+
* This hook is run in both Vite build and serve commands.
|
|
28
|
+
* This hook is run in Node.js.
|
|
29
|
+
*/
|
|
30
|
+
onConfigUpdated?(): Promise<void> | void;
|
|
31
|
+
onPreSave?(ctx: CmsEventHookContext): Promise<void> | void;
|
|
32
|
+
/**
|
|
33
|
+
* Skip initializing until you call `CMS.init`
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* // Browser
|
|
37
|
+
* window.CMS.init()
|
|
38
|
+
* // Node.js
|
|
39
|
+
* import cms from 'decap-cms-app'
|
|
40
|
+
*
|
|
41
|
+
* cms.init()
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
useManualInitialization?: boolean;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
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;
|
|
48
|
+
type KeysToSnakeCase<T> = {
|
|
49
|
+
[K in keyof T as CamelToSnakeCase<string & K, 'i18n'>]: T[K];
|
|
50
|
+
};
|
|
51
|
+
type CamelCase<S extends string> = S extends `${infer P1}_${infer P2}${infer P3}` ? `${Lowercase<P1>}${Uppercase<P2>}${CamelCase<P3>}` : Lowercase<S>;
|
|
52
|
+
type KeysToCamelCase<T> = {
|
|
53
|
+
[K in keyof T as CamelCase<string & K>]: T[K] extends {} ? KeysToCamelCase<T[K]> : T[K];
|
|
54
|
+
};
|
|
55
|
+
type PickRequired<O extends object, K extends keyof O> = Omit<O, K> & Required<Pick<O, K>>;
|
|
56
|
+
type CollectionType = 'file' | 'folder';
|
|
57
|
+
type DecapCmsMarkdownFieldRenderOptions = KeysToCamelCase<Omit<CmsFieldMarkdown, 'widget' | 'default' | 'editorComponents'>>;
|
|
58
|
+
type DecapCmsField = KeysToCamelCase<CmsField>;
|
|
59
|
+
type DecapCmsFieldType = NonNullable<Exclude<CmsField, CmsFieldMeta>['widget']>;
|
|
60
|
+
type DecapCmsWidget = Exclude<CmsField, CmsFieldStringOrText | CmsFieldMeta> | (CmsFieldBase & PickRequired<CmsFieldStringOrText, 'widget'>);
|
|
61
|
+
type DecapCmsFieldWidget<Name extends DecapCmsFieldType> = DecapCmsWidget extends infer K ? K extends DecapCmsWidget ? Name extends K['widget'] ? K : never : never : never;
|
|
62
|
+
type DecapCmsCollectionFile = KeysToCamelCase<Omit<CmsCollectionFile, 'fields'>> & {
|
|
63
|
+
fields: DecapCmsField[];
|
|
64
|
+
};
|
|
65
|
+
type BaseDecapCmsCollection<Props> = KeysToCamelCase<Omit<CmsCollection, 'files' | 'fields'>> & Props;
|
|
66
|
+
type DecapCmsCollection<Type extends CollectionType = CollectionType> = Type extends 'folder' ? BaseDecapCmsCollection<{
|
|
67
|
+
fields: DecapCmsField[];
|
|
68
|
+
}> : Type extends 'file' ? BaseDecapCmsCollection<{
|
|
69
|
+
files: DecapCmsCollectionFile[];
|
|
70
|
+
}> : never;
|
|
71
|
+
type DecapCmsConfig = KeysToCamelCase<Omit<CmsConfig, 'local_backend' | 'backend' | 'collections' | 'load_config_file'>> & {
|
|
72
|
+
backend: {
|
|
73
|
+
local?: boolean | 'dev' | KeysToCamelCase<CmsLocalBackend>;
|
|
74
|
+
/**
|
|
75
|
+
* Overwrite the branch specified in `backend.branch`
|
|
76
|
+
* - true: always use current branch
|
|
77
|
+
* - false: always use the branch in the configuration
|
|
78
|
+
* - 'dev': only use the current branch when locally writing
|
|
79
|
+
* - 'prod': ony use the current branch when building the site
|
|
80
|
+
* @default false
|
|
81
|
+
*/
|
|
82
|
+
useCurrentBranch?: boolean | 'dev' | 'prod';
|
|
83
|
+
} & KeysToCamelCase<CmsBackend>;
|
|
84
|
+
collections: DecapCmsCollection[];
|
|
85
|
+
/**
|
|
86
|
+
* The subfolder for where to write the CMS configuration (config.yml):
|
|
87
|
+
* - '' for the {@link Options.dir}
|
|
88
|
+
* @default 'admin'
|
|
89
|
+
*/
|
|
90
|
+
dir?: string;
|
|
91
|
+
};
|
|
92
|
+
type CdnLinkOptions = string | {
|
|
93
|
+
version?: string;
|
|
94
|
+
base?: string;
|
|
95
|
+
};
|
|
96
|
+
interface LoginPageOptions {
|
|
97
|
+
title?: string;
|
|
98
|
+
head?: string[];
|
|
99
|
+
}
|
|
100
|
+
type YmlStringifyOptions = Parameters<typeof yaml.stringify>;
|
|
101
|
+
interface Options {
|
|
102
|
+
/**
|
|
103
|
+
* How to load Decap CMS
|
|
104
|
+
* @default
|
|
105
|
+
* { method: 'cdn'}
|
|
106
|
+
*/
|
|
107
|
+
load?: {
|
|
108
|
+
method: 'cdn';
|
|
109
|
+
options?: CdnLinkOptions;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Log when the configuration is being written or skipped
|
|
113
|
+
*/
|
|
114
|
+
debug?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* The folder where to write all /admin/ files.
|
|
117
|
+
* Will create an `admin` folder at this path if it does not exist.
|
|
118
|
+
*
|
|
119
|
+
* @default vite.Config.publicDir
|
|
120
|
+
*/
|
|
121
|
+
dir?: string;
|
|
122
|
+
/**
|
|
123
|
+
* Options for the index.html (login page) file
|
|
124
|
+
*/
|
|
125
|
+
login?: LoginPageOptions;
|
|
126
|
+
config: DecapCmsConfig;
|
|
127
|
+
/**
|
|
128
|
+
* Run custom JS to enhance the CMS
|
|
129
|
+
*/
|
|
130
|
+
script?: ScriptOptions;
|
|
131
|
+
/**
|
|
132
|
+
* Yml stringify options for writing the config.yml file
|
|
133
|
+
*/
|
|
134
|
+
yml?: {
|
|
135
|
+
replacer?: NonNullable<YmlStringifyOptions[1]>;
|
|
136
|
+
options?: NonNullable<YmlStringifyOptions[2]>;
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
declare function getGitData(): {
|
|
141
|
+
readonly branch: string | undefined;
|
|
142
|
+
readonly commitSha: string | undefined;
|
|
143
|
+
};
|
|
144
|
+
declare function createField<T extends DecapCmsFieldType>(widget: T, data: Omit<DecapCmsFieldWidget<T>, 'widget'>): DecapCmsFieldWidget<T>;
|
|
145
|
+
declare function createFolderCollection(data: DecapCmsCollection<'folder'>): KeysToCamelCase<Omit<decap_cms_core.CmsCollection, "files" | "fields">> & {
|
|
146
|
+
fields: DecapCmsField[];
|
|
147
|
+
};
|
|
148
|
+
declare function createFile(data: DecapCmsCollectionFile): DecapCmsCollectionFile;
|
|
149
|
+
declare function createFileCollection(data: DecapCmsCollection<'file'>): KeysToCamelCase<Omit<decap_cms_core.CmsCollection, "files" | "fields">> & {
|
|
150
|
+
files: DecapCmsCollectionFile[];
|
|
151
|
+
};
|
|
152
|
+
type OverwriteOptions = Omit<CmsFieldBase, 'name'> & {
|
|
153
|
+
/**
|
|
154
|
+
* Hide this field in the CMS editor UI.
|
|
155
|
+
* @default false
|
|
156
|
+
*/
|
|
157
|
+
hidden?: boolean;
|
|
158
|
+
};
|
|
159
|
+
type VitePressPageFrontmatterKeys = 'title' | 'titleTemplate' | 'description' | 'head' | 'body';
|
|
160
|
+
interface BaseVitePressFieldOptions<Keys extends string> {
|
|
161
|
+
overwrites?: Partial<Record<Keys, OverwriteOptions>>;
|
|
162
|
+
}
|
|
163
|
+
interface VitePressFieldOptions extends BaseVitePressFieldOptions<VitePressPageFrontmatterKeys> {
|
|
164
|
+
additionalFields?: DecapCmsField[];
|
|
165
|
+
/**
|
|
166
|
+
* Options for the markdown editor in the CMS
|
|
167
|
+
*/
|
|
168
|
+
markdownOptions?: DecapCmsMarkdownFieldRenderOptions;
|
|
169
|
+
}
|
|
170
|
+
type VitePressDefaultThemeFrontmatterKeys = 'navbar' | 'sidebar' | 'aside' | 'outline' | 'lastUpdated' | 'editLink' | 'footer' | 'pageClass';
|
|
171
|
+
type VitePressDefaultThemeFieldOptions = BaseVitePressFieldOptions<VitePressDefaultThemeFrontmatterKeys>;
|
|
172
|
+
declare class VitePress {
|
|
173
|
+
/**
|
|
174
|
+
* Create fields for:
|
|
175
|
+
* - navbar
|
|
176
|
+
* - sidebar
|
|
177
|
+
* - aside
|
|
178
|
+
* - outline
|
|
179
|
+
* - lastUpdated
|
|
180
|
+
* - editLink
|
|
181
|
+
* - footer
|
|
182
|
+
* - pageClass
|
|
183
|
+
*
|
|
184
|
+
* Does not create the default page fields, such as title and description.
|
|
185
|
+
* @param options Options for overwriting field data
|
|
186
|
+
* @see https://vitepress.dev/reference/frontmatter-config#default-theme-only
|
|
187
|
+
*/
|
|
188
|
+
static createDefaultThemeNormalPageFields(options?: VitePressDefaultThemeFieldOptions): DecapCmsField[];
|
|
189
|
+
/**
|
|
190
|
+
* Create fields for:
|
|
191
|
+
* - title
|
|
192
|
+
* - titleTemplate
|
|
193
|
+
* - description
|
|
194
|
+
* - head
|
|
195
|
+
* @param options.overwrites Overwrite data, such as labels, for the fields
|
|
196
|
+
* @see https://vitepress.dev/reference/frontmatter-config
|
|
197
|
+
*/
|
|
198
|
+
static createDefaultPageFields(options?: VitePressFieldOptions): DecapCmsField[];
|
|
199
|
+
static createDefaultPageFolderCollection(name: string, folder: string, options?: VitePressFieldOptions & {
|
|
200
|
+
collection?: Partial<Omit<DecapCmsCollection<'folder'>, 'name' | 'fields' | 'folder'>>;
|
|
201
|
+
}): DecapCmsCollection<'folder'>;
|
|
202
|
+
static createDefaultPageFile(name: string, file: string, options?: VitePressFieldOptions & {
|
|
203
|
+
collection?: Partial<Omit<DecapCmsCollectionFile, 'name' | 'file'>>;
|
|
204
|
+
}): DecapCmsCollectionFile;
|
|
205
|
+
static createDefaultPageFileCollection(name: string, files: Parameters<typeof VitePress['createDefaultPageFile']>[], options?: {
|
|
206
|
+
collection?: Partial<Omit<DecapCmsCollection<'file'>, 'name' | 'files'>>;
|
|
207
|
+
}): KeysToCamelCase<Omit<decap_cms_core.CmsCollection, "files" | "fields">> & {
|
|
208
|
+
files: DecapCmsCollectionFile[];
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
declare function VitePluginDecapCMS(options: Options): {
|
|
213
|
+
name: string;
|
|
214
|
+
configResolved(this: void, config: Readonly<Omit<vite.UserConfig, "plugins" | "css" | "assetsInclude" | "optimizeDeps" | "worker" | "build"> & {
|
|
215
|
+
configFile: string | undefined;
|
|
216
|
+
configFileDependencies: string[];
|
|
217
|
+
inlineConfig: vite.InlineConfig;
|
|
218
|
+
root: string;
|
|
219
|
+
base: string;
|
|
220
|
+
publicDir: string;
|
|
221
|
+
cacheDir: string;
|
|
222
|
+
command: "build" | "serve";
|
|
223
|
+
mode: string;
|
|
224
|
+
isWorker: boolean;
|
|
225
|
+
isProduction: boolean;
|
|
226
|
+
envDir: string;
|
|
227
|
+
env: Record<string, any>;
|
|
228
|
+
resolve: Required<vite.ResolveOptions> & {
|
|
229
|
+
alias: vite.Alias[];
|
|
230
|
+
};
|
|
231
|
+
plugins: readonly Plugin<any>[];
|
|
232
|
+
css: vite.ResolvedCSSOptions;
|
|
233
|
+
esbuild: false | vite.ESBuildOptions;
|
|
234
|
+
server: vite.ResolvedServerOptions;
|
|
235
|
+
build: vite.ResolvedBuildOptions;
|
|
236
|
+
preview: vite.ResolvedPreviewOptions;
|
|
237
|
+
ssr: vite.ResolvedSSROptions;
|
|
238
|
+
assetsInclude: (file: string) => boolean;
|
|
239
|
+
logger: vite.Logger;
|
|
240
|
+
createResolver: (options?: Partial<vite.InternalResolveOptions> | undefined) => vite.ResolveFn;
|
|
241
|
+
optimizeDeps: vite.DepOptimizationOptions;
|
|
242
|
+
worker: vite.ResolvedWorkerOptions;
|
|
243
|
+
appType: vite.AppType;
|
|
244
|
+
experimental: vite.ExperimentalOptions;
|
|
245
|
+
} & vite.PluginHookUtils>): Promise<void>;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
export { type CdnLinkOptions, type CollectionType, type DecapCmsCollection, type DecapCmsCollectionFile, type DecapCmsConfig, type DecapCmsField, type DecapCmsFieldType, type DecapCmsFieldWidget, type DecapCmsMarkdownFieldRenderOptions, type KeysToCamelCase, type KeysToSnakeCase, type LoginPageOptions, type Options, type OverwriteOptions, VitePress, type VitePressDefaultThemeFieldOptions, type VitePressDefaultThemeFrontmatterKeys, type VitePressFieldOptions, type VitePressPageFrontmatterKeys, createField, createFile, createFileCollection, createFolderCollection, VitePluginDecapCMS as default, getGitData };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import * as vite from 'vite';
|
|
2
|
+
import { Plugin } from 'vite';
|
|
3
|
+
import * as yaml from 'yaml';
|
|
4
|
+
import * as decap_cms_core from 'decap-cms-core';
|
|
5
|
+
import { CmsEventListener, CMS, CmsFieldMarkdown, CmsField, CmsFieldMeta, CmsCollectionFile, CmsConfig, CmsLocalBackend, CmsBackend, CmsFieldStringOrText, CmsFieldBase, CmsCollection } from 'decap-cms-core';
|
|
6
|
+
|
|
7
|
+
interface CmsHookContext {
|
|
8
|
+
app: CMS;
|
|
9
|
+
}
|
|
10
|
+
type CmsEventHookContext = CmsHookContext & Parameters<CmsEventListener['handler']>[0];
|
|
11
|
+
type ScriptOptions = {
|
|
12
|
+
[event in `on${Capitalize<CmsEventListener['name']>}`]?: (ctx: CmsEventHookContext) => Promise<void> | void;
|
|
13
|
+
} & {
|
|
14
|
+
/**
|
|
15
|
+
* Called when the admin UI is initialized.
|
|
16
|
+
* This hook is run in the browser.
|
|
17
|
+
* @param ctx
|
|
18
|
+
*/
|
|
19
|
+
onInitialized?(ctx: CmsHookContext): Promise<void> | void;
|
|
20
|
+
/**
|
|
21
|
+
* Called when the config is written in builds.
|
|
22
|
+
* This hook is run in Node.js.
|
|
23
|
+
*/
|
|
24
|
+
onGenerated?(): Promise<void> | void;
|
|
25
|
+
/**
|
|
26
|
+
* Called when the config is written.
|
|
27
|
+
* This hook is run in both Vite build and serve commands.
|
|
28
|
+
* This hook is run in Node.js.
|
|
29
|
+
*/
|
|
30
|
+
onConfigUpdated?(): Promise<void> | void;
|
|
31
|
+
onPreSave?(ctx: CmsEventHookContext): Promise<void> | void;
|
|
32
|
+
/**
|
|
33
|
+
* Skip initializing until you call `CMS.init`
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* // Browser
|
|
37
|
+
* window.CMS.init()
|
|
38
|
+
* // Node.js
|
|
39
|
+
* import cms from 'decap-cms-app'
|
|
40
|
+
*
|
|
41
|
+
* cms.init()
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
useManualInitialization?: boolean;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
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;
|
|
48
|
+
type KeysToSnakeCase<T> = {
|
|
49
|
+
[K in keyof T as CamelToSnakeCase<string & K, 'i18n'>]: T[K];
|
|
50
|
+
};
|
|
51
|
+
type CamelCase<S extends string> = S extends `${infer P1}_${infer P2}${infer P3}` ? `${Lowercase<P1>}${Uppercase<P2>}${CamelCase<P3>}` : Lowercase<S>;
|
|
52
|
+
type KeysToCamelCase<T> = {
|
|
53
|
+
[K in keyof T as CamelCase<string & K>]: T[K] extends {} ? KeysToCamelCase<T[K]> : T[K];
|
|
54
|
+
};
|
|
55
|
+
type PickRequired<O extends object, K extends keyof O> = Omit<O, K> & Required<Pick<O, K>>;
|
|
56
|
+
type CollectionType = 'file' | 'folder';
|
|
57
|
+
type DecapCmsMarkdownFieldRenderOptions = KeysToCamelCase<Omit<CmsFieldMarkdown, 'widget' | 'default' | 'editorComponents'>>;
|
|
58
|
+
type DecapCmsField = KeysToCamelCase<CmsField>;
|
|
59
|
+
type DecapCmsFieldType = NonNullable<Exclude<CmsField, CmsFieldMeta>['widget']>;
|
|
60
|
+
type DecapCmsWidget = Exclude<CmsField, CmsFieldStringOrText | CmsFieldMeta> | (CmsFieldBase & PickRequired<CmsFieldStringOrText, 'widget'>);
|
|
61
|
+
type DecapCmsFieldWidget<Name extends DecapCmsFieldType> = DecapCmsWidget extends infer K ? K extends DecapCmsWidget ? Name extends K['widget'] ? K : never : never : never;
|
|
62
|
+
type DecapCmsCollectionFile = KeysToCamelCase<Omit<CmsCollectionFile, 'fields'>> & {
|
|
63
|
+
fields: DecapCmsField[];
|
|
64
|
+
};
|
|
65
|
+
type BaseDecapCmsCollection<Props> = KeysToCamelCase<Omit<CmsCollection, 'files' | 'fields'>> & Props;
|
|
66
|
+
type DecapCmsCollection<Type extends CollectionType = CollectionType> = Type extends 'folder' ? BaseDecapCmsCollection<{
|
|
67
|
+
fields: DecapCmsField[];
|
|
68
|
+
}> : Type extends 'file' ? BaseDecapCmsCollection<{
|
|
69
|
+
files: DecapCmsCollectionFile[];
|
|
70
|
+
}> : never;
|
|
71
|
+
type DecapCmsConfig = KeysToCamelCase<Omit<CmsConfig, 'local_backend' | 'backend' | 'collections' | 'load_config_file'>> & {
|
|
72
|
+
backend: {
|
|
73
|
+
local?: boolean | 'dev' | KeysToCamelCase<CmsLocalBackend>;
|
|
74
|
+
/**
|
|
75
|
+
* Overwrite the branch specified in `backend.branch`
|
|
76
|
+
* - true: always use current branch
|
|
77
|
+
* - false: always use the branch in the configuration
|
|
78
|
+
* - 'dev': only use the current branch when locally writing
|
|
79
|
+
* - 'prod': ony use the current branch when building the site
|
|
80
|
+
* @default false
|
|
81
|
+
*/
|
|
82
|
+
useCurrentBranch?: boolean | 'dev' | 'prod';
|
|
83
|
+
} & KeysToCamelCase<CmsBackend>;
|
|
84
|
+
collections: DecapCmsCollection[];
|
|
85
|
+
/**
|
|
86
|
+
* The subfolder for where to write the CMS configuration (config.yml):
|
|
87
|
+
* - '' for the {@link Options.dir}
|
|
88
|
+
* @default 'admin'
|
|
89
|
+
*/
|
|
90
|
+
dir?: string;
|
|
91
|
+
};
|
|
92
|
+
type CdnLinkOptions = string | {
|
|
93
|
+
version?: string;
|
|
94
|
+
base?: string;
|
|
95
|
+
};
|
|
96
|
+
interface LoginPageOptions {
|
|
97
|
+
title?: string;
|
|
98
|
+
head?: string[];
|
|
99
|
+
}
|
|
100
|
+
type YmlStringifyOptions = Parameters<typeof yaml.stringify>;
|
|
101
|
+
interface Options {
|
|
102
|
+
/**
|
|
103
|
+
* How to load Decap CMS
|
|
104
|
+
* @default
|
|
105
|
+
* { method: 'cdn'}
|
|
106
|
+
*/
|
|
107
|
+
load?: {
|
|
108
|
+
method: 'cdn';
|
|
109
|
+
options?: CdnLinkOptions;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Log when the configuration is being written or skipped
|
|
113
|
+
*/
|
|
114
|
+
debug?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* The folder where to write all /admin/ files.
|
|
117
|
+
* Will create an `admin` folder at this path if it does not exist.
|
|
118
|
+
*
|
|
119
|
+
* @default vite.Config.publicDir
|
|
120
|
+
*/
|
|
121
|
+
dir?: string;
|
|
122
|
+
/**
|
|
123
|
+
* Options for the index.html (login page) file
|
|
124
|
+
*/
|
|
125
|
+
login?: LoginPageOptions;
|
|
126
|
+
config: DecapCmsConfig;
|
|
127
|
+
/**
|
|
128
|
+
* Run custom JS to enhance the CMS
|
|
129
|
+
*/
|
|
130
|
+
script?: ScriptOptions;
|
|
131
|
+
/**
|
|
132
|
+
* Yml stringify options for writing the config.yml file
|
|
133
|
+
*/
|
|
134
|
+
yml?: {
|
|
135
|
+
replacer?: NonNullable<YmlStringifyOptions[1]>;
|
|
136
|
+
options?: NonNullable<YmlStringifyOptions[2]>;
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
declare function getGitData(): {
|
|
141
|
+
readonly branch: string | undefined;
|
|
142
|
+
readonly commitSha: string | undefined;
|
|
143
|
+
};
|
|
144
|
+
declare function createField<T extends DecapCmsFieldType>(widget: T, data: Omit<DecapCmsFieldWidget<T>, 'widget'>): DecapCmsFieldWidget<T>;
|
|
145
|
+
declare function createFolderCollection(data: DecapCmsCollection<'folder'>): KeysToCamelCase<Omit<decap_cms_core.CmsCollection, "files" | "fields">> & {
|
|
146
|
+
fields: DecapCmsField[];
|
|
147
|
+
};
|
|
148
|
+
declare function createFile(data: DecapCmsCollectionFile): DecapCmsCollectionFile;
|
|
149
|
+
declare function createFileCollection(data: DecapCmsCollection<'file'>): KeysToCamelCase<Omit<decap_cms_core.CmsCollection, "files" | "fields">> & {
|
|
150
|
+
files: DecapCmsCollectionFile[];
|
|
151
|
+
};
|
|
152
|
+
type OverwriteOptions = Omit<CmsFieldBase, 'name'> & {
|
|
153
|
+
/**
|
|
154
|
+
* Hide this field in the CMS editor UI.
|
|
155
|
+
* @default false
|
|
156
|
+
*/
|
|
157
|
+
hidden?: boolean;
|
|
158
|
+
};
|
|
159
|
+
type VitePressPageFrontmatterKeys = 'title' | 'titleTemplate' | 'description' | 'head' | 'body';
|
|
160
|
+
interface BaseVitePressFieldOptions<Keys extends string> {
|
|
161
|
+
overwrites?: Partial<Record<Keys, OverwriteOptions>>;
|
|
162
|
+
}
|
|
163
|
+
interface VitePressFieldOptions extends BaseVitePressFieldOptions<VitePressPageFrontmatterKeys> {
|
|
164
|
+
additionalFields?: DecapCmsField[];
|
|
165
|
+
/**
|
|
166
|
+
* Options for the markdown editor in the CMS
|
|
167
|
+
*/
|
|
168
|
+
markdownOptions?: DecapCmsMarkdownFieldRenderOptions;
|
|
169
|
+
}
|
|
170
|
+
type VitePressDefaultThemeFrontmatterKeys = 'navbar' | 'sidebar' | 'aside' | 'outline' | 'lastUpdated' | 'editLink' | 'footer' | 'pageClass';
|
|
171
|
+
type VitePressDefaultThemeFieldOptions = BaseVitePressFieldOptions<VitePressDefaultThemeFrontmatterKeys>;
|
|
172
|
+
declare class VitePress {
|
|
173
|
+
/**
|
|
174
|
+
* Create fields for:
|
|
175
|
+
* - navbar
|
|
176
|
+
* - sidebar
|
|
177
|
+
* - aside
|
|
178
|
+
* - outline
|
|
179
|
+
* - lastUpdated
|
|
180
|
+
* - editLink
|
|
181
|
+
* - footer
|
|
182
|
+
* - pageClass
|
|
183
|
+
*
|
|
184
|
+
* Does not create the default page fields, such as title and description.
|
|
185
|
+
* @param options Options for overwriting field data
|
|
186
|
+
* @see https://vitepress.dev/reference/frontmatter-config#default-theme-only
|
|
187
|
+
*/
|
|
188
|
+
static createDefaultThemeNormalPageFields(options?: VitePressDefaultThemeFieldOptions): DecapCmsField[];
|
|
189
|
+
/**
|
|
190
|
+
* Create fields for:
|
|
191
|
+
* - title
|
|
192
|
+
* - titleTemplate
|
|
193
|
+
* - description
|
|
194
|
+
* - head
|
|
195
|
+
* @param options.overwrites Overwrite data, such as labels, for the fields
|
|
196
|
+
* @see https://vitepress.dev/reference/frontmatter-config
|
|
197
|
+
*/
|
|
198
|
+
static createDefaultPageFields(options?: VitePressFieldOptions): DecapCmsField[];
|
|
199
|
+
static createDefaultPageFolderCollection(name: string, folder: string, options?: VitePressFieldOptions & {
|
|
200
|
+
collection?: Partial<Omit<DecapCmsCollection<'folder'>, 'name' | 'fields' | 'folder'>>;
|
|
201
|
+
}): DecapCmsCollection<'folder'>;
|
|
202
|
+
static createDefaultPageFile(name: string, file: string, options?: VitePressFieldOptions & {
|
|
203
|
+
collection?: Partial<Omit<DecapCmsCollectionFile, 'name' | 'file'>>;
|
|
204
|
+
}): DecapCmsCollectionFile;
|
|
205
|
+
static createDefaultPageFileCollection(name: string, files: Parameters<typeof VitePress['createDefaultPageFile']>[], options?: {
|
|
206
|
+
collection?: Partial<Omit<DecapCmsCollection<'file'>, 'name' | 'files'>>;
|
|
207
|
+
}): KeysToCamelCase<Omit<decap_cms_core.CmsCollection, "files" | "fields">> & {
|
|
208
|
+
files: DecapCmsCollectionFile[];
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
declare function VitePluginDecapCMS(options: Options): {
|
|
213
|
+
name: string;
|
|
214
|
+
configResolved(this: void, config: Readonly<Omit<vite.UserConfig, "plugins" | "css" | "assetsInclude" | "optimizeDeps" | "worker" | "build"> & {
|
|
215
|
+
configFile: string | undefined;
|
|
216
|
+
configFileDependencies: string[];
|
|
217
|
+
inlineConfig: vite.InlineConfig;
|
|
218
|
+
root: string;
|
|
219
|
+
base: string;
|
|
220
|
+
publicDir: string;
|
|
221
|
+
cacheDir: string;
|
|
222
|
+
command: "build" | "serve";
|
|
223
|
+
mode: string;
|
|
224
|
+
isWorker: boolean;
|
|
225
|
+
isProduction: boolean;
|
|
226
|
+
envDir: string;
|
|
227
|
+
env: Record<string, any>;
|
|
228
|
+
resolve: Required<vite.ResolveOptions> & {
|
|
229
|
+
alias: vite.Alias[];
|
|
230
|
+
};
|
|
231
|
+
plugins: readonly Plugin<any>[];
|
|
232
|
+
css: vite.ResolvedCSSOptions;
|
|
233
|
+
esbuild: false | vite.ESBuildOptions;
|
|
234
|
+
server: vite.ResolvedServerOptions;
|
|
235
|
+
build: vite.ResolvedBuildOptions;
|
|
236
|
+
preview: vite.ResolvedPreviewOptions;
|
|
237
|
+
ssr: vite.ResolvedSSROptions;
|
|
238
|
+
assetsInclude: (file: string) => boolean;
|
|
239
|
+
logger: vite.Logger;
|
|
240
|
+
createResolver: (options?: Partial<vite.InternalResolveOptions> | undefined) => vite.ResolveFn;
|
|
241
|
+
optimizeDeps: vite.DepOptimizationOptions;
|
|
242
|
+
worker: vite.ResolvedWorkerOptions;
|
|
243
|
+
appType: vite.AppType;
|
|
244
|
+
experimental: vite.ExperimentalOptions;
|
|
245
|
+
} & vite.PluginHookUtils>): Promise<void>;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
export { type CdnLinkOptions, type CollectionType, type DecapCmsCollection, type DecapCmsCollectionFile, type DecapCmsConfig, type DecapCmsField, type DecapCmsFieldType, type DecapCmsFieldWidget, type DecapCmsMarkdownFieldRenderOptions, type KeysToCamelCase, type KeysToSnakeCase, type LoginPageOptions, type Options, type OverwriteOptions, VitePress, type VitePressDefaultThemeFieldOptions, type VitePressDefaultThemeFrontmatterKeys, type VitePressFieldOptions, type VitePressPageFrontmatterKeys, createField, createFile, createFileCollection, createFolderCollection, VitePluginDecapCMS as default, getGitData };
|