@docusaurus/types 2.0.0-beta.20 → 2.0.0-beta.22
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/package.json +9 -7
- package/src/clientModule.d.ts +19 -0
- package/src/config.d.ts +283 -0
- package/src/context.d.ts +62 -0
- package/src/i18n.d.ts +82 -0
- package/src/index.d.ts +70 -742
- package/src/plugin.d.ts +195 -0
- package/src/routing.d.ts +138 -0
- package/src/swizzle.d.ts +43 -0
- package/src/utils.d.ts +14 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/types",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.22",
|
|
4
4
|
"description": "Common types for Docusaurus packages.",
|
|
5
5
|
"types": "./src/index.d.ts",
|
|
6
6
|
"publishConfig": {
|
|
@@ -12,17 +12,19 @@
|
|
|
12
12
|
"directory": "packages/docusaurus-types"
|
|
13
13
|
},
|
|
14
14
|
"license": "MIT",
|
|
15
|
-
"scripts": {
|
|
16
|
-
"test": "tsc -p ."
|
|
17
|
-
},
|
|
18
15
|
"dependencies": {
|
|
16
|
+
"@types/history": "^4.7.11",
|
|
17
|
+
"@types/react": "*",
|
|
19
18
|
"commander": "^5.1.0",
|
|
20
|
-
"history": "^4.9.0",
|
|
21
19
|
"joi": "^17.6.0",
|
|
22
20
|
"react-helmet-async": "^1.3.0",
|
|
23
21
|
"utility-types": "^3.10.0",
|
|
24
|
-
"webpack": "^5.
|
|
22
|
+
"webpack": "^5.73.0",
|
|
25
23
|
"webpack-merge": "^5.8.0"
|
|
26
24
|
},
|
|
27
|
-
"
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"react": "^16.8.4 || ^17.0.0",
|
|
27
|
+
"react-dom": "^16.8.4 || ^17.0.0"
|
|
28
|
+
},
|
|
29
|
+
"gitHead": "daf9e462c4eebb7ac26a940932311f987e768f87"
|
|
28
30
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type {Location} from 'history';
|
|
9
|
+
|
|
10
|
+
export type ClientModule = {
|
|
11
|
+
onRouteDidUpdate?: (args: {
|
|
12
|
+
previousLocation: Location | null;
|
|
13
|
+
location: Location;
|
|
14
|
+
}) => (() => void) | void;
|
|
15
|
+
onRouteUpdate?: (args: {
|
|
16
|
+
previousLocation: Location | null;
|
|
17
|
+
location: Location;
|
|
18
|
+
}) => (() => void) | void;
|
|
19
|
+
};
|
package/src/config.d.ts
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type {RuleSetRule} from 'webpack';
|
|
9
|
+
import type {Required as RequireKeys, DeepPartial} from 'utility-types';
|
|
10
|
+
import type {I18nConfig} from './i18n';
|
|
11
|
+
import type {PluginConfig, PresetConfig} from './plugin';
|
|
12
|
+
|
|
13
|
+
export type ReportingSeverity = 'ignore' | 'log' | 'warn' | 'throw';
|
|
14
|
+
|
|
15
|
+
export type ThemeConfig = {
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Docusaurus config, after validation/normalization.
|
|
21
|
+
*/
|
|
22
|
+
export type DocusaurusConfig = {
|
|
23
|
+
/**
|
|
24
|
+
* Title for your website. Will be used in metadata and as browser tab title.
|
|
25
|
+
*
|
|
26
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#title
|
|
27
|
+
*/
|
|
28
|
+
title: string;
|
|
29
|
+
/**
|
|
30
|
+
* URL for your website. This can also be considered the top-level hostname.
|
|
31
|
+
* For example, `https://facebook.github.io` is the URL of
|
|
32
|
+
* https://facebook.github.io/metro/, and `https://docusaurus.io` is the URL
|
|
33
|
+
* for https://docusaurus.io.
|
|
34
|
+
*
|
|
35
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#url
|
|
36
|
+
*/
|
|
37
|
+
url: string;
|
|
38
|
+
/**
|
|
39
|
+
* Can be considered as the path after the host. For example, `/metro/` is the
|
|
40
|
+
* base URL of https://facebook.github.io/metro/. For URLs that have no path,
|
|
41
|
+
* it should be set to `/`. Always has both leading and trailing slash.
|
|
42
|
+
*
|
|
43
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#baseUrl
|
|
44
|
+
*/
|
|
45
|
+
baseUrl: string;
|
|
46
|
+
/**
|
|
47
|
+
* Path to your site favicon; must be a URL that can be used in link's href.
|
|
48
|
+
*
|
|
49
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#favicon
|
|
50
|
+
*/
|
|
51
|
+
favicon?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Allow to customize the presence/absence of a trailing slash at the end of
|
|
54
|
+
* URLs/links, and how static HTML files are generated:
|
|
55
|
+
*
|
|
56
|
+
* - `undefined` (default): keeps URLs untouched, and emit
|
|
57
|
+
* `/docs/myDoc/index.html` for `/docs/myDoc.md`
|
|
58
|
+
* - `true`: add trailing slashes to URLs/links, and emit
|
|
59
|
+
* `/docs/myDoc/index.html` for `/docs/myDoc.md`
|
|
60
|
+
* - `false`: remove trailing slashes from URLs/links, and emit
|
|
61
|
+
* `/docs/myDoc.html` for `/docs/myDoc.md`
|
|
62
|
+
*
|
|
63
|
+
* @see https://github.com/slorber/trailing-slash-guide
|
|
64
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#trailingSlash
|
|
65
|
+
* @default undefined
|
|
66
|
+
*/
|
|
67
|
+
trailingSlash: boolean | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* The i18n configuration object to [localize your
|
|
70
|
+
* site](https://docusaurus.io/docs/i18n/introduction).
|
|
71
|
+
*
|
|
72
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#i18n
|
|
73
|
+
*/
|
|
74
|
+
i18n: I18nConfig;
|
|
75
|
+
/**
|
|
76
|
+
* This option adds `<meta name="robots" content="noindex, nofollow">` to
|
|
77
|
+
* every page to tell search engines to avoid indexing your site.
|
|
78
|
+
*
|
|
79
|
+
* @see https://moz.com/learn/seo/robots-meta-directives
|
|
80
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#noIndex
|
|
81
|
+
* @default false
|
|
82
|
+
*/
|
|
83
|
+
noIndex: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* The behavior of Docusaurus when it detects any broken link.
|
|
86
|
+
*
|
|
87
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#onBrokenLinks
|
|
88
|
+
* @default "throw"
|
|
89
|
+
*/
|
|
90
|
+
onBrokenLinks: ReportingSeverity;
|
|
91
|
+
/**
|
|
92
|
+
* The behavior of Docusaurus when it detects any broken markdown link.
|
|
93
|
+
*
|
|
94
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#onBrokenMarkdownLinks
|
|
95
|
+
* @default "warn"
|
|
96
|
+
*/
|
|
97
|
+
onBrokenMarkdownLinks: ReportingSeverity;
|
|
98
|
+
/**
|
|
99
|
+
* The behavior of Docusaurus when it detects any [duplicate
|
|
100
|
+
* routes](https://docusaurus.io/docs/creating-pages#duplicate-routes).
|
|
101
|
+
*
|
|
102
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#onDuplicateRoutes
|
|
103
|
+
* @default "warn"
|
|
104
|
+
*/
|
|
105
|
+
onDuplicateRoutes: ReportingSeverity;
|
|
106
|
+
/**
|
|
107
|
+
* The tagline for your website.
|
|
108
|
+
*
|
|
109
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#tagline
|
|
110
|
+
* @default ""
|
|
111
|
+
*/
|
|
112
|
+
tagline: string;
|
|
113
|
+
/**
|
|
114
|
+
* The GitHub user or organization that owns the repository. You don't need
|
|
115
|
+
* this if you are not using the `docusaurus deploy` command.
|
|
116
|
+
*
|
|
117
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#organizationName
|
|
118
|
+
*/
|
|
119
|
+
organizationName?: string;
|
|
120
|
+
/**
|
|
121
|
+
* The name of the GitHub repository. You don't need this if you are not using
|
|
122
|
+
* the `docusaurus deploy` command.
|
|
123
|
+
*
|
|
124
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#projectName
|
|
125
|
+
*/
|
|
126
|
+
projectName?: string;
|
|
127
|
+
/**
|
|
128
|
+
* The name of the branch to deploy the static files to. You don't need this
|
|
129
|
+
* if you are not using the `docusaurus deploy` command.
|
|
130
|
+
*
|
|
131
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#deploymentBranch
|
|
132
|
+
*/
|
|
133
|
+
deploymentBranch?: string;
|
|
134
|
+
/**
|
|
135
|
+
* The hostname of your server. Useful if you are using GitHub Enterprise. You
|
|
136
|
+
* don't need this if you are not using the `docusaurus deploy` command.
|
|
137
|
+
*
|
|
138
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#githubHost
|
|
139
|
+
*/
|
|
140
|
+
githubHost?: string;
|
|
141
|
+
/**
|
|
142
|
+
* The port of your server. Useful if you are using GitHub Enterprise. You
|
|
143
|
+
* don't need this if you are not using the `docusaurus deploy` command.
|
|
144
|
+
*
|
|
145
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#githubPort
|
|
146
|
+
*/
|
|
147
|
+
githubPort?: string;
|
|
148
|
+
/**
|
|
149
|
+
* The [theme configuration](https://docusaurus.io/docs/api/themes/configuration)
|
|
150
|
+
* object to customize your site UI like navbar and footer.
|
|
151
|
+
*
|
|
152
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#themeConfig
|
|
153
|
+
* @default {}
|
|
154
|
+
*/
|
|
155
|
+
themeConfig: ThemeConfig;
|
|
156
|
+
/**
|
|
157
|
+
* List of plugins.
|
|
158
|
+
*
|
|
159
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#plugins
|
|
160
|
+
* @default []
|
|
161
|
+
*/
|
|
162
|
+
plugins: PluginConfig[];
|
|
163
|
+
/**
|
|
164
|
+
* List of themes.
|
|
165
|
+
*
|
|
166
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#themes
|
|
167
|
+
* @default []
|
|
168
|
+
*/
|
|
169
|
+
themes: PluginConfig[];
|
|
170
|
+
/**
|
|
171
|
+
* List of presets.
|
|
172
|
+
*
|
|
173
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#presets
|
|
174
|
+
* @default []
|
|
175
|
+
*/
|
|
176
|
+
presets: PresetConfig[];
|
|
177
|
+
/**
|
|
178
|
+
* Docusaurus guards `docusaurus.config.js` from unknown fields. To add a
|
|
179
|
+
* custom field, define it on `customFields`.
|
|
180
|
+
*
|
|
181
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#customFields
|
|
182
|
+
* @default {}
|
|
183
|
+
*/
|
|
184
|
+
customFields?: {
|
|
185
|
+
[key: string]: unknown;
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* An array of paths, relative to the site's directory or absolute. Files
|
|
189
|
+
* under these paths will be copied to the build output as-is.
|
|
190
|
+
*
|
|
191
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#staticDirectories
|
|
192
|
+
* @default ["static"]
|
|
193
|
+
*/
|
|
194
|
+
staticDirectories: string[];
|
|
195
|
+
/**
|
|
196
|
+
* An array of scripts to load. The values can be either strings or plain
|
|
197
|
+
* objects of attribute-value maps. The `<script>` tags will be inserted in
|
|
198
|
+
* the HTML `<head>`.
|
|
199
|
+
*
|
|
200
|
+
* Note that `<script>` added here are render-blocking, so you might want to
|
|
201
|
+
* add `async: true`/`defer: true` to the objects.
|
|
202
|
+
*
|
|
203
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#scripts
|
|
204
|
+
* @default []
|
|
205
|
+
*/
|
|
206
|
+
scripts: (
|
|
207
|
+
| string
|
|
208
|
+
| {
|
|
209
|
+
src: string;
|
|
210
|
+
[key: string]: string | boolean | undefined;
|
|
211
|
+
}
|
|
212
|
+
)[];
|
|
213
|
+
/**
|
|
214
|
+
* An array of CSS sources to load. The values can be either strings or plain
|
|
215
|
+
* objects of attribute-value maps. The `<link>` tags will be inserted in the
|
|
216
|
+
* HTML `<head>`.
|
|
217
|
+
*
|
|
218
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#stylesheets
|
|
219
|
+
* @default []
|
|
220
|
+
*/
|
|
221
|
+
stylesheets: (
|
|
222
|
+
| string
|
|
223
|
+
| {
|
|
224
|
+
href: string;
|
|
225
|
+
[key: string]: string | boolean | undefined;
|
|
226
|
+
}
|
|
227
|
+
)[];
|
|
228
|
+
/**
|
|
229
|
+
* An array of [client modules](https://docusaurus.io/docs/advanced/client#client-modules)
|
|
230
|
+
* to load globally on your site.
|
|
231
|
+
*
|
|
232
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#clientModules
|
|
233
|
+
* @default []
|
|
234
|
+
*/
|
|
235
|
+
clientModules: string[];
|
|
236
|
+
/**
|
|
237
|
+
* An HTML template written in [Eta's syntax](https://eta.js.org/docs/syntax#syntax-overview)
|
|
238
|
+
* that will be used to render your application. This can be used to set
|
|
239
|
+
* custom attributes on the `body` tags, additional `meta` tags, customize the
|
|
240
|
+
* `viewport`, etc. Please note that Docusaurus will rely on the template to
|
|
241
|
+
* be correctly structured in order to function properly, once you do
|
|
242
|
+
* customize it, you will have to make sure that your template is compliant
|
|
243
|
+
* with the requirements from upstream.
|
|
244
|
+
*
|
|
245
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#ssrTemplate
|
|
246
|
+
*/
|
|
247
|
+
ssrTemplate?: string;
|
|
248
|
+
/**
|
|
249
|
+
* Will be used as title delimiter in the generated `<title>` tag.
|
|
250
|
+
*
|
|
251
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#titleDelimiter
|
|
252
|
+
* @default "|"
|
|
253
|
+
*/
|
|
254
|
+
titleDelimiter: string;
|
|
255
|
+
/**
|
|
256
|
+
* When enabled, will show a banner in case your site can't load its CSS or
|
|
257
|
+
* JavaScript files, which is a very common issue, often related to a wrong
|
|
258
|
+
* `baseUrl` in site config.
|
|
259
|
+
*
|
|
260
|
+
* @see https://docusaurus.io/docs/api/docusaurus-config#baseUrlIssueBanner
|
|
261
|
+
* @default true
|
|
262
|
+
*/
|
|
263
|
+
baseUrlIssueBanner: boolean;
|
|
264
|
+
/** Webpack-related options. */
|
|
265
|
+
webpack?: {
|
|
266
|
+
/**
|
|
267
|
+
* Configuration for alternative JS loaders. "babel" will use the built-in
|
|
268
|
+
* Babel loader and preset; otherwise, you can provide your custom Webpack
|
|
269
|
+
* rule set.
|
|
270
|
+
*/
|
|
271
|
+
jsLoader: 'babel' | ((isServer: boolean) => RuleSetRule);
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Docusaurus config, as provided by the user (partial/unnormalized). This type
|
|
277
|
+
* is used to provide type-safety / IDE auto-complete on the config file.
|
|
278
|
+
* @see https://docusaurus.io/docs/typescript-support
|
|
279
|
+
*/
|
|
280
|
+
export type Config = RequireKeys<
|
|
281
|
+
DeepPartial<DocusaurusConfig>,
|
|
282
|
+
'title' | 'url' | 'baseUrl'
|
|
283
|
+
>;
|
package/src/context.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import type {DocusaurusConfig} from './config';
|
|
8
|
+
import type {CodeTranslations, I18n} from './i18n';
|
|
9
|
+
import type {LoadedPlugin, PluginVersionInformation} from './plugin';
|
|
10
|
+
import type {RouteConfig} from './routing';
|
|
11
|
+
|
|
12
|
+
export type DocusaurusContext = {
|
|
13
|
+
siteConfig: DocusaurusConfig;
|
|
14
|
+
siteMetadata: SiteMetadata;
|
|
15
|
+
globalData: GlobalData;
|
|
16
|
+
i18n: I18n;
|
|
17
|
+
codeTranslations: CodeTranslations;
|
|
18
|
+
|
|
19
|
+
// Don't put mutable values here, to avoid triggering re-renders
|
|
20
|
+
// We could reconsider that choice if context selectors are implemented
|
|
21
|
+
// isBrowser: boolean; // Not here on purpose!
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type SiteMetadata = {
|
|
25
|
+
readonly docusaurusVersion: string;
|
|
26
|
+
readonly siteVersion?: string;
|
|
27
|
+
readonly pluginVersions: {[pluginName: string]: PluginVersionInformation};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type GlobalData = {[pluginName: string]: {[pluginId: string]: unknown}};
|
|
31
|
+
|
|
32
|
+
export type LoadContext = {
|
|
33
|
+
siteDir: string;
|
|
34
|
+
generatedFilesDir: string;
|
|
35
|
+
siteConfig: DocusaurusConfig;
|
|
36
|
+
siteConfigPath: string;
|
|
37
|
+
outDir: string;
|
|
38
|
+
/**
|
|
39
|
+
* Directory where all source translations for the current locale can be found
|
|
40
|
+
* in. Constructed with `i18n.path` + `i18n.currentLocale.path` (e.g.
|
|
41
|
+
* `<siteDir>/i18n/en`)
|
|
42
|
+
*/
|
|
43
|
+
localizationDir: string;
|
|
44
|
+
/**
|
|
45
|
+
* Duplicated from `siteConfig.baseUrl`, but probably worth keeping. We mutate
|
|
46
|
+
* `siteConfig` to make `baseUrl` there localized as well, but that's mostly
|
|
47
|
+
* for client-side. `context.baseUrl` is still more convenient for plugins.
|
|
48
|
+
*/
|
|
49
|
+
baseUrl: string;
|
|
50
|
+
i18n: I18n;
|
|
51
|
+
codeTranslations: CodeTranslations;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export type Props = LoadContext & {
|
|
55
|
+
headTags: string;
|
|
56
|
+
preBodyTags: string;
|
|
57
|
+
postBodyTags: string;
|
|
58
|
+
siteMetadata: SiteMetadata;
|
|
59
|
+
routes: RouteConfig[];
|
|
60
|
+
routesPaths: string[];
|
|
61
|
+
plugins: LoadedPlugin[];
|
|
62
|
+
};
|
package/src/i18n.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type {DeepRequired} from 'utility-types';
|
|
9
|
+
|
|
10
|
+
export type I18nLocaleConfig = {
|
|
11
|
+
/** The label displayed for this locale in the locales dropdown. */
|
|
12
|
+
label: string;
|
|
13
|
+
/**
|
|
14
|
+
* BCP 47 language tag to use in `<html lang="...">` and in
|
|
15
|
+
* `<link ... hreflang="...">`
|
|
16
|
+
*/
|
|
17
|
+
htmlLang: string;
|
|
18
|
+
/** Used to select the locale's CSS and html meta attribute. */
|
|
19
|
+
direction: 'ltr' | 'rtl';
|
|
20
|
+
/**
|
|
21
|
+
* The [calendar](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar)
|
|
22
|
+
* used to calculate the date era. Note that it doesn't control the actual
|
|
23
|
+
* string displayed: `MM/DD/YYYY` and `DD/MM/YYYY` are both gregory. To choose
|
|
24
|
+
* the format (`DD/MM/YYYY` or `MM/DD/YYYY`), set your locale name to `en-GB`
|
|
25
|
+
* or `en-US` (`en` means `en-US`).
|
|
26
|
+
*/
|
|
27
|
+
calendar: string;
|
|
28
|
+
/**
|
|
29
|
+
* Root folder that all plugin localization folders of this locale are
|
|
30
|
+
* relative to. Will be resolved against `i18n.path`. Defaults to the locale's
|
|
31
|
+
* name.
|
|
32
|
+
*/
|
|
33
|
+
path: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type I18nConfig = {
|
|
37
|
+
/**
|
|
38
|
+
* The locale that:
|
|
39
|
+
* 1. Does not have its name in the base URL
|
|
40
|
+
* 2. Gets started with `docusaurus start` without `--locale` option
|
|
41
|
+
* 3. Will be used for the `<link hrefLang="x-default">` tag
|
|
42
|
+
*/
|
|
43
|
+
defaultLocale: string;
|
|
44
|
+
/**
|
|
45
|
+
* Root folder which all locale folders are relative to. Can be absolute or
|
|
46
|
+
* relative to the config file. e.g. `i18n`
|
|
47
|
+
*/
|
|
48
|
+
path: string;
|
|
49
|
+
/** List of locales deployed on your site. Must contain `defaultLocale`. */
|
|
50
|
+
locales: [string, ...string[]];
|
|
51
|
+
/** Individual options for each locale. */
|
|
52
|
+
localeConfigs: {[locale: string]: Partial<I18nLocaleConfig>};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export type I18n = DeepRequired<I18nConfig> & {currentLocale: string};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Inspired by Chrome JSON, because it's a widely supported i18n format
|
|
59
|
+
* @see https://developer.chrome.com/apps/i18n-messages
|
|
60
|
+
* @see https://support.crowdin.com/file-formats/chrome-json/
|
|
61
|
+
* @see https://www.applanga.com/docs/formats/chrome_i18n_json
|
|
62
|
+
* @see https://docs.transifex.com/formats/chrome-json
|
|
63
|
+
* @see https://help.phrase.com/help/chrome-json-messages
|
|
64
|
+
*/
|
|
65
|
+
export type TranslationMessage = {message: string; description?: string};
|
|
66
|
+
export type TranslationFileContent = {[msgId: string]: TranslationMessage};
|
|
67
|
+
/**
|
|
68
|
+
* An abstract representation of how a translation file exists on disk. The core
|
|
69
|
+
* would handle the file reading/writing; plugins just need to deal with
|
|
70
|
+
* translations in-memory.
|
|
71
|
+
*/
|
|
72
|
+
export type TranslationFile = {
|
|
73
|
+
/**
|
|
74
|
+
* Relative to the directory where it's expected to be found. For plugin
|
|
75
|
+
* files, it's relative to `i18n/<locale>/<pluginName>/<pluginId>`. Should NOT
|
|
76
|
+
* have any extension.
|
|
77
|
+
*/
|
|
78
|
+
path: string;
|
|
79
|
+
content: TranslationFileContent;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export type CodeTranslations = {[msgId: string]: string};
|