forked from facebook/docusaurus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.d.ts
395 lines (377 loc) · 12.3 KB
/
config.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type {RuleSetRule} from 'webpack';
import type {Required as RequireKeys, DeepPartial} from 'utility-types';
import type {I18nConfig} from './i18n';
import type {PluginConfig, PresetConfig, HtmlTagObject} from './plugin';
import type {ProcessorOptions} from '@mdx-js/mdx';
export type RemarkRehypeOptions = ProcessorOptions['remarkRehypeOptions'];
export type ReportingSeverity = 'ignore' | 'log' | 'warn' | 'throw';
export type ThemeConfig = {
[key: string]: unknown;
};
export type MarkdownPreprocessor = (args: {
filePath: string;
fileContent: string;
}) => string;
export type MDX1CompatOptions = {
comments: boolean;
admonitions: boolean;
headingIds: boolean;
};
export type ParseFrontMatterParams = {filePath: string; fileContent: string};
export type ParseFrontMatterResult = {
frontMatter: {[key: string]: unknown};
content: string;
};
export type DefaultParseFrontMatter = (
params: ParseFrontMatterParams,
) => Promise<ParseFrontMatterResult>;
export type ParseFrontMatter = (
params: ParseFrontMatterParams & {
defaultParseFrontMatter: DefaultParseFrontMatter;
},
) => Promise<ParseFrontMatterResult>;
export type MarkdownConfig = {
/**
* The Markdown format to use by default.
*
* This is the format passed down to the MDX compiler, impacting the way the
* content is parsed.
*
* Possible values:
* - `'mdx'`: use the MDX format (JSX support)
* - `'md'`: use the CommonMark format (no JSX support)
* - `'detect'`: select the format based on file extension (.md / .mdx)
*
* @see https://mdxjs.com/packages/mdx/#optionsformat
* @default 'mdx'
*/
format: 'mdx' | 'md' | 'detect';
/**
* A function callback that lets users parse the front matter themselves.
* Gives the opportunity to read it from a different source, or process it.
*
* @see https://github.com/facebook/docusaurus/issues/5568
*/
parseFrontMatter: ParseFrontMatter;
/**
* Allow mermaid language code blocks to be rendered into Mermaid diagrams:
*
* - `true`: code blocks with language mermaid will be rendered.
* - `false` | `undefined` (default): code blocks with language mermaid
* will be left as code blocks.
*
* @see https://docusaurus.io/docs/markdown-features/diagrams/
* @default false
*/
mermaid: boolean;
/**
* Gives opportunity to preprocess the MDX string content before compiling.
* A good escape hatch that can be used to handle edge cases.
*
* @param args
*/
preprocessor?: MarkdownPreprocessor;
/**
* Set of flags make it easier to upgrade from MDX 1 to MDX 2
* See also https://github.com/facebook/docusaurus/issues/4029
*/
mdx1Compat: MDX1CompatOptions;
/**
* Ability to provide custom remark-rehype options
* See also https://github.com/remarkjs/remark-rehype#options
*/
remarkRehypeOptions: RemarkRehypeOptions;
/**
* Ability to preserve the case of the heading anchor links.
* See also https://github.com/facebook/docusaurus/issues/7946
*/
anchors?: {
maintainCase: boolean;
};
};
/**
* Docusaurus config, after validation/normalization.
*/
export type DocusaurusConfig = {
/**
* Title for your website. Will be used in metadata and as browser tab title.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#title
*/
title: string;
/**
* URL for your website. This can also be considered the top-level hostname.
* For example, `https://facebook.github.io` is the URL of
* https://facebook.github.io/metro/, and `https://docusaurus.io` is the URL
* for https://docusaurus.io.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#url
*/
url: string;
/**
* Can be considered as the path after the host. For example, `/metro/` is the
* base URL of https://facebook.github.io/metro/. For URLs that have no path,
* it should be set to `/`. Always has both leading and trailing slash.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#baseUrl
*/
baseUrl: string;
/**
* Path to your site favicon; must be a URL that can be used in link's href.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#favicon
*/
favicon?: string;
/**
* Allow to customize the presence/absence of a trailing slash at the end of
* URLs/links, and how static HTML files are generated:
*
* - `undefined` (default): keeps URLs untouched, and emit
* `/docs/myDoc/index.html` for `/docs/myDoc.md`
* - `true`: add trailing slashes to URLs/links, and emit
* `/docs/myDoc/index.html` for `/docs/myDoc.md`
* - `false`: remove trailing slashes from URLs/links, and emit
* `/docs/myDoc.html` for `/docs/myDoc.md`
*
* @see https://github.com/slorber/trailing-slash-guide
* @see https://docusaurus.io/docs/api/docusaurus-config#trailingSlash
* @default undefined
*/
trailingSlash: boolean | undefined;
/**
* The i18n configuration object to [localize your
* site](https://docusaurus.io/docs/i18n/introduction).
*
* @see https://docusaurus.io/docs/api/docusaurus-config#i18n
*/
i18n: I18nConfig;
/**
* This option adds `<meta name="robots" content="noindex, nofollow">` to
* every page to tell search engines to avoid indexing your site.
*
* @see https://moz.com/learn/seo/robots-meta-directives
* @see https://docusaurus.io/docs/api/docusaurus-config#noIndex
* @default false
*/
noIndex: boolean;
/**
* The behavior of Docusaurus when it detects any broken link.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#onBrokenLinks
* @default "throw"
*/
onBrokenLinks: ReportingSeverity;
/**
* The behavior of Docusaurus when it detects any broken link.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#onBrokenAnchors
* @default "warn"
*/
onBrokenAnchors: ReportingSeverity;
/**
* The behavior of Docusaurus when it detects any broken markdown link.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#onBrokenMarkdownLinks
* @default "warn"
*/
onBrokenMarkdownLinks: ReportingSeverity;
/**
* The behavior of Docusaurus when it detects any [duplicate
* routes](https://docusaurus.io/docs/creating-pages#duplicate-routes).
*
* @see https://docusaurus.io/docs/api/docusaurus-config#onDuplicateRoutes
* @default "warn"
*/
onDuplicateRoutes: ReportingSeverity;
/**
* The tagline for your website.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#tagline
* @default ""
*/
tagline: string;
/**
* The GitHub user or organization that owns the repository. You don't need
* this if you are not using the `docusaurus deploy` command.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#organizationName
*/
organizationName?: string;
/**
* The name of the GitHub repository. You don't need this if you are not using
* the `docusaurus deploy` command.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#projectName
*/
projectName?: string;
/**
* The name of the branch to deploy the static files to. You don't need this
* if you are not using the `docusaurus deploy` command.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#deploymentBranch
*/
deploymentBranch?: string;
/**
* The hostname of your server. Useful if you are using GitHub Enterprise. You
* don't need this if you are not using the `docusaurus deploy` command.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#githubHost
*/
githubHost?: string;
/**
* The port of your server. Useful if you are using GitHub Enterprise. You
* don't need this if you are not using the `docusaurus deploy` command.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#githubPort
*/
githubPort?: string;
/**
* The [theme configuration](https://docusaurus.io/docs/api/themes/configuration)
* object to customize your site UI like navbar and footer.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#themeConfig
* @default {}
*/
themeConfig: ThemeConfig;
/**
* List of plugins.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#plugins
* @default []
*/
plugins: PluginConfig[];
/**
* List of themes.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#themes
* @default []
*/
themes: PluginConfig[];
/**
* List of presets.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#presets
* @default []
*/
presets: PresetConfig[];
/**
* Docusaurus guards `docusaurus.config.js` from unknown fields. To add a
* custom field, define it on `customFields`.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#customFields
* @default {}
*/
customFields?: {
[key: string]: unknown;
};
/**
* An array of paths, relative to the site's directory or absolute. Files
* under these paths will be copied to the build output as-is.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#staticDirectories
* @default ["static"]
*/
staticDirectories: string[];
/**
* An array of tags that will be inserted in the HTML `<head>`.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#head
* @default []
*/
headTags: HtmlTagObject[];
/**
* An array of scripts to load. The values can be either strings or plain
* objects of attribute-value maps. The `<script>` tags will be inserted in
* the HTML `<head>`.
*
* Note that `<script>` added here are render-blocking, so you might want to
* add `async: true`/`defer: true` to the objects.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#scripts
* @default []
*/
scripts: (
| string
| {
src: string;
[key: string]: string | boolean | undefined;
}
)[];
/**
* An array of CSS sources to load. The values can be either strings or plain
* objects of attribute-value maps. The `<link>` tags will be inserted in the
* HTML `<head>`.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#stylesheets
* @default []
*/
stylesheets: (
| string
| {
href: string;
[key: string]: string | boolean | undefined;
}
)[];
/**
* An array of [client modules](https://docusaurus.io/docs/advanced/client#client-modules)
* to load globally on your site.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#clientModules
* @default []
*/
clientModules: string[];
/**
* An HTML template written in [Eta's syntax](https://eta.js.org/docs/syntax#syntax-overview)
* that will be used to render your application. This can be used to set
* custom attributes on the `body` tags, additional `meta` tags, customize the
* `viewport`, etc. Please note that Docusaurus will rely on the template to
* be correctly structured in order to function properly, once you do
* customize it, you will have to make sure that your template is compliant
* with the requirements from upstream.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#ssrTemplate
*/
ssrTemplate?: string;
/**
* Will be used as title delimiter in the generated `<title>` tag.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#titleDelimiter
* @default "|"
*/
titleDelimiter: string;
/**
* When enabled, will show a banner in case your site can't load its CSS or
* JavaScript files, which is a very common issue, often related to a wrong
* `baseUrl` in site config.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#baseUrlIssueBanner
* @default true
*/
baseUrlIssueBanner: boolean;
/** Webpack-related options. */
webpack?: {
/**
* Configuration for alternative JS loaders. "babel" will use the built-in
* Babel loader and preset; otherwise, you can provide your custom Webpack
* rule set.
*/
jsLoader: 'babel' | ((isServer: boolean) => RuleSetRule);
};
/** Markdown-related options. */
markdown: MarkdownConfig;
};
/**
* Docusaurus config, as provided by the user (partial/unnormalized). This type
* is used to provide type-safety / IDE auto-complete on the config file.
* @see https://docusaurus.io/docs/typescript-support
*/
export type Config = RequireKeys<
DeepPartial<DocusaurusConfig>,
'title' | 'url' | 'baseUrl'
>;