@docusaurus/plugin-content-docs 2.0.0-beta.18 → 2.0.0-beta.19

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.
Files changed (76) hide show
  1. package/lib/categoryGeneratedIndex.d.ts +1 -1
  2. package/lib/categoryGeneratedIndex.js +4 -2
  3. package/lib/cli.d.ts +3 -2
  4. package/lib/cli.js +45 -35
  5. package/lib/client/docsClientUtils.d.ts +6 -5
  6. package/lib/client/docsClientUtils.js +8 -10
  7. package/lib/client/index.d.ts +9 -8
  8. package/lib/client/index.js +30 -33
  9. package/lib/constants.d.ts +4 -0
  10. package/lib/constants.js +4 -1
  11. package/lib/docs.d.ts +5 -3
  12. package/lib/docs.js +18 -13
  13. package/lib/frontMatter.d.ts +1 -1
  14. package/lib/frontMatter.js +3 -0
  15. package/lib/globalData.d.ts +2 -2
  16. package/lib/globalData.js +6 -6
  17. package/lib/index.d.ts +1 -2
  18. package/lib/index.js +31 -23
  19. package/lib/markdown/linkify.js +1 -2
  20. package/lib/props.d.ts +3 -3
  21. package/lib/props.js +7 -6
  22. package/lib/routes.d.ts +5 -4
  23. package/lib/routes.js +9 -23
  24. package/lib/server-export.d.ts +2 -1
  25. package/lib/server-export.js +3 -4
  26. package/lib/sidebars/generator.js +3 -3
  27. package/lib/sidebars/index.js +0 -2
  28. package/lib/sidebars/normalization.js +1 -1
  29. package/lib/sidebars/postProcessor.js +2 -2
  30. package/lib/sidebars/processor.js +14 -3
  31. package/lib/sidebars/types.d.ts +18 -14
  32. package/lib/sidebars/utils.d.ts +3 -3
  33. package/lib/slug.d.ts +1 -2
  34. package/lib/tags.d.ts +2 -1
  35. package/lib/tags.js +1 -1
  36. package/lib/translations.d.ts +3 -3
  37. package/lib/translations.js +3 -53
  38. package/lib/types.d.ts +8 -96
  39. package/lib/versions/files.d.ts +44 -0
  40. package/lib/versions/files.js +142 -0
  41. package/lib/versions/index.d.ts +36 -0
  42. package/lib/versions/index.js +155 -0
  43. package/lib/versions/validation.d.ts +17 -0
  44. package/lib/versions/validation.js +71 -0
  45. package/package.json +14 -12
  46. package/src/categoryGeneratedIndex.ts +8 -3
  47. package/src/cli.ts +62 -65
  48. package/src/client/docsClientUtils.ts +11 -13
  49. package/src/client/index.ts +41 -42
  50. package/src/constants.ts +4 -2
  51. package/src/docs.ts +41 -26
  52. package/src/frontMatter.ts +6 -3
  53. package/src/globalData.ts +10 -10
  54. package/src/index.ts +44 -38
  55. package/src/markdown/linkify.ts +2 -3
  56. package/src/plugin-content-docs.d.ts +447 -113
  57. package/src/props.ts +12 -9
  58. package/src/routes.ts +13 -39
  59. package/src/server-export.ts +1 -3
  60. package/src/sidebars/generator.ts +4 -4
  61. package/src/sidebars/index.ts +0 -2
  62. package/src/sidebars/normalization.ts +1 -1
  63. package/src/sidebars/postProcessor.ts +2 -2
  64. package/src/sidebars/processor.ts +24 -5
  65. package/src/sidebars/types.ts +20 -19
  66. package/src/sidebars/utils.ts +6 -3
  67. package/src/slug.ts +4 -2
  68. package/src/tags.ts +3 -2
  69. package/src/translations.ts +10 -61
  70. package/src/types.ts +13 -106
  71. package/src/versions/files.ts +220 -0
  72. package/src/versions/index.ts +247 -0
  73. package/src/versions/validation.ts +113 -0
  74. package/lib/versions.d.ts +0 -41
  75. package/lib/versions.js +0 -324
  76. package/src/versions.ts +0 -606
@@ -6,18 +6,32 @@
6
6
  */
7
7
 
8
8
  declare module '@docusaurus/plugin-content-docs' {
9
- import type {RemarkAndRehypePluginOptions} from '@docusaurus/mdx-loader';
10
-
11
- export interface Assets {
9
+ import type {MDXOptions} from '@docusaurus/mdx-loader';
10
+ import type {
11
+ ContentPaths,
12
+ FrontMatterTag,
13
+ TagsListItem,
14
+ TagModule,
15
+ Tag,
16
+ } from '@docusaurus/utils';
17
+ import type {Plugin, LoadContext} from '@docusaurus/types';
18
+ import type {Required} from 'utility-types';
19
+
20
+ export type Assets = {
12
21
  image?: string;
13
- }
22
+ };
14
23
 
24
+ /**
25
+ * Custom callback for parsing number prefixes from file/folder names.
26
+ */
15
27
  export type NumberPrefixParser = (filename: string) => {
28
+ /** File name without number prefix, without any other modification. */
16
29
  filename: string;
30
+ /** The number prefix. Can be float, integer, negative, or anything. */
17
31
  numberPrefix?: number;
18
32
  };
19
33
 
20
- export type CategoryIndexMatcherParam = {
34
+ export type CategoryIndexMatcher = (param: {
21
35
  /** The file name, without extension */
22
36
  fileName: string;
23
37
  /**
@@ -27,113 +41,453 @@ declare module '@docusaurus/plugin-content-docs' {
27
41
  directories: string[];
28
42
  /** The extension, with a leading dot */
29
43
  extension: string;
30
- };
31
- export type CategoryIndexMatcher = (
32
- param: CategoryIndexMatcherParam,
33
- ) => boolean;
44
+ }) => boolean;
34
45
 
35
46
  export type EditUrlFunction = (editUrlParams: {
47
+ /** Name of the version. */
36
48
  version: string;
49
+ /**
50
+ * Path of the version's root content path, relative to the site directory.
51
+ * Usually the same as `options.path` but can be localized or versioned.
52
+ */
37
53
  versionDocsDirPath: string;
54
+ /** Path of the doc file, relative to `versionDocsDirPath`. */
38
55
  docPath: string;
56
+ /** @see {@link DocMetadata.permalink} */
39
57
  permalink: string;
58
+ /** Locale name. */
40
59
  locale: string;
41
60
  }) => string | undefined;
42
61
 
43
62
  export type MetadataOptions = {
63
+ /**
64
+ * URL route for the docs section of your site. **DO NOT** include a
65
+ * trailing slash. Use `/` for shipping docs without base path.
66
+ */
44
67
  routeBasePath: string;
68
+ /**
69
+ * Base URL to edit your site. The final URL is computed by `editUrl +
70
+ * relativeDocPath`. Using a function allows more nuanced control for each
71
+ * file. Omitting this variable entirely will disable edit links.
72
+ */
45
73
  editUrl?: string | EditUrlFunction;
74
+ /**
75
+ * The edit URL will always target the current version doc instead of older
76
+ * versions. Ignored when `editUrl` is a function.
77
+ */
46
78
  editCurrentVersion: boolean;
79
+ /**
80
+ * The edit URL will target the localized file, instead of the original
81
+ * unlocalized file. Ignored when `editUrl` is a function.
82
+ */
47
83
  editLocalizedFiles: boolean;
84
+ /** Whether to display the last date the doc was updated. */
48
85
  showLastUpdateTime?: boolean;
86
+ /** Whether to display the author who last updated the doc. */
49
87
  showLastUpdateAuthor?: boolean;
88
+ /**
89
+ * Custom parsing logic to extract number prefixes from file names. Use
90
+ * `false` to disable this behavior and leave the docs untouched, and `true`
91
+ * to use the default parser.
92
+ *
93
+ * @param filename One segment of the path, without any slashes.
94
+ * @see https://docusaurus.io/docs/sidebar#using-number-prefixes
95
+ */
50
96
  numberPrefixParser: NumberPrefixParser;
97
+ /** Enable or disable the breadcrumbs on doc pages. */
51
98
  breadcrumbs: boolean;
52
99
  };
53
100
 
54
101
  export type PathOptions = {
102
+ /**
103
+ * Path to the docs content directory on the file system, relative to site
104
+ * directory.
105
+ */
55
106
  path: string;
107
+ /**
108
+ * Path to sidebar configuration. Use `false` to disable sidebars, or
109
+ * `undefined` to create a fully autogenerated sidebar.
110
+ */
56
111
  sidebarPath?: string | false | undefined;
57
112
  };
58
113
 
59
114
  // TODO support custom version banner?
60
115
  // {type: "error", content: "html content"}
61
116
  export type VersionBanner = 'unreleased' | 'unmaintained';
62
- export type VersionOptions = {
63
- path?: string;
64
- label?: string;
65
- banner?: 'none' | VersionBanner;
66
- badge?: boolean;
67
- className?: string;
68
- };
69
117
  export type VersionsOptions = {
118
+ /**
119
+ * The version navigated to in priority and displayed by default for docs
120
+ * navbar items.
121
+ *
122
+ * @see https://docusaurus.io/docs/versioning#terminology
123
+ */
70
124
  lastVersion?: string;
71
- versions: {[versionName: string]: VersionOptions};
125
+ /** Only include a subset of all available versions. */
72
126
  onlyIncludeVersions?: string[];
127
+ /**
128
+ * Explicitly disable versioning even when multiple versions exist. This
129
+ * will make the site only include the current version. Will error if
130
+ * `includeCurrentVersion: false` and `disableVersioning: true`.
131
+ */
132
+ disableVersioning: boolean;
133
+ /** Include the current version of your docs. */
134
+ includeCurrentVersion: boolean;
135
+ /** Independent customization of each version's properties. */
136
+ versions: {
137
+ [versionName: string]: {
138
+ /**
139
+ * The base path of the version, will be appended to `baseUrl` +
140
+ * `routeBasePath`.
141
+ */
142
+ path?: string;
143
+ /** The label of the version to be used in badges, dropdowns, etc. */
144
+ label?: string;
145
+ /** The banner to show at the top of a doc of that version. */
146
+ banner?: 'none' | VersionBanner;
147
+ /** Show a badge with the version label at the top of each doc. */
148
+ badge?: boolean;
149
+ /** Add a custom class name to the <html> element of each doc. */
150
+ className?: string;
151
+ };
152
+ };
73
153
  };
74
154
  export type SidebarOptions = {
155
+ /**
156
+ * Whether sidebar categories are collapsible by default.
157
+ *
158
+ * @see https://docusaurus.io/docs/sidebar#collapsible-categories
159
+ */
75
160
  sidebarCollapsible: boolean;
161
+ /**
162
+ * Whether sidebar categories are collapsed by default.
163
+ *
164
+ * @see https://docusaurus.io/docs/sidebar#expanded-categories-by-default
165
+ */
76
166
  sidebarCollapsed: boolean;
77
167
  };
78
168
 
79
169
  export type PluginOptions = MetadataOptions &
80
170
  PathOptions &
81
171
  VersionsOptions &
82
- RemarkAndRehypePluginOptions &
172
+ MDXOptions &
83
173
  SidebarOptions & {
174
+ /** Plugin ID. */
84
175
  id: string;
176
+ /**
177
+ * Array of glob patterns matching Markdown files to be built, relative to
178
+ * the content path.
179
+ */
85
180
  include: string[];
181
+ /**
182
+ * Array of glob patterns matching Markdown files to be excluded. Serves
183
+ * as refinement based on the `include` option.
184
+ */
86
185
  exclude: string[];
186
+ /**
187
+ * Root layout component of each doc page. Provides the version data
188
+ * context, and is not unmounted when switching docs.
189
+ */
87
190
  docLayoutComponent: string;
191
+ /** Main doc container, with TOC, pagination, etc. */
88
192
  docItemComponent: string;
193
+ /** Root component of the "docs containing tag X" page. */
89
194
  docTagDocListComponent: string;
195
+ /** Root component of the tags list page */
90
196
  docTagsListComponent: string;
197
+ /** Root component of the generated category index page. */
91
198
  docCategoryGeneratedIndexComponent: string;
92
199
  admonitions: {[key: string]: unknown};
93
- disableVersioning: boolean;
94
- includeCurrentVersion: boolean;
95
200
  sidebarItemsGenerator: import('./sidebars/types').SidebarItemsGeneratorOption;
201
+ /**
202
+ * URL route for the tags section of your doc version. Will be appended to
203
+ * `routeBasePath`. **DO NOT** include a trailing slash.
204
+ */
96
205
  tagsBasePath: string;
97
206
  };
98
207
  export type Options = Partial<PluginOptions>;
99
208
  export type SidebarsConfig = import('./sidebars/types').SidebarsConfig;
100
209
 
210
+ export type VersionMetadata = ContentPaths & {
211
+ /** A name like `1.0.0`. Acquired from `versions.json`. */
212
+ versionName: string;
213
+ /** Like `Version 1.0.0`. Can be configured through `versions.label`. */
214
+ label: string;
215
+ /**
216
+ * Version's base path in the form of `/<baseUrl>/<routeBasePath>/1.0.0`.
217
+ * Can be configured through `versions.path`.
218
+ */
219
+ path: string;
220
+ /** Tags base path in the form of `<versionPath>/tags`. */
221
+ tagsPath: string;
222
+ /**
223
+ * The base URL to which the doc file path will be appended. Will be
224
+ * `undefined` if `editUrl` is `undefined` or a function.
225
+ */
226
+ editUrl?: string | undefined;
227
+ /**
228
+ * The base URL to which the localized doc file path will be appended. Will
229
+ * be `undefined` if `editUrl` is `undefined` or a function.
230
+ */
231
+ editUrlLocalized?: string | undefined;
232
+ /**
233
+ * "unmaintained" is the version before latest; "unreleased" is the version
234
+ * after latest. `null` is the latest version without a banner. Can be
235
+ * configured with `versions.banner`: `banner: "none"` will be transformed
236
+ * to `null` here.
237
+ */
238
+ banner: VersionBanner | null;
239
+ /** Show a badge with the version label at the top of each doc. */
240
+ badge: boolean;
241
+ /** Add a custom class name to the <html> element of each doc. */
242
+ className: string;
243
+ /**
244
+ * Whether this version is the "last" version. Can be configured with
245
+ * `lastVersion` option.
246
+ */
247
+ isLast: boolean;
248
+ /**
249
+ * Like `versioned_sidebars/1.0.0.json`. Versioned sidebars file may be
250
+ * nonexistent since we don't create empty files.
251
+ */
252
+ sidebarFilePath: string | false | undefined;
253
+ /**
254
+ * Will be -1 for the latest docs, and `undefined` for everything else.
255
+ * Because `/docs/foo` should always be after `/docs/<versionName>/foo`.
256
+ */
257
+ routePriority: number | undefined;
258
+ };
259
+
260
+ export type DocFrontMatter = {
261
+ /**
262
+ * The last part of the doc ID (will be refactored in the future to be the
263
+ * full ID instead)
264
+ * @see {@link DocMetadata.id}
265
+ */
266
+ id?: string;
267
+ /**
268
+ * Will override the default title collected from h1 heading.
269
+ * @see {@link DocMetadata.title}
270
+ */
271
+ title?: string;
272
+ /**
273
+ * Front matter tags, unnormalized.
274
+ * @see {@link DocMetadata.tags}
275
+ */
276
+ tags?: FrontMatterTag[];
277
+ /**
278
+ * If there isn't a Markdown h1 heading (which, if there is, we don't
279
+ * remove), this front matter will cause the front matter title to not be
280
+ * displayed in the doc page.
281
+ */
282
+ hide_title?: boolean;
283
+ /** Hide the TOC on the right. */
284
+ hide_table_of_contents?: boolean;
285
+ /** Used in the head meta. */
286
+ keywords?: string[];
287
+ /** Used in the head meta. Should use `assets.image` in priority. */
288
+ image?: string;
289
+ /**
290
+ * Will override the default excerpt.
291
+ * @see {@link DocMetadata.description}
292
+ */
293
+ description?: string;
294
+ /**
295
+ * Custom slug appended after /<baseUrl>/<routeBasePath>/<versionPath>
296
+ * @see {@link DocMetadata.slug}
297
+ */
298
+ slug?: string;
299
+ /** Customizes the sidebar label for this doc. Will default to its title. */
300
+ sidebar_label?: string;
301
+ /**
302
+ * Controls the position of a doc inside the generated sidebar slice when
303
+ * using autogenerated sidebar items.
304
+ *
305
+ * @see https://docusaurus.io/docs/sidebar#autogenerated-sidebar-metadata
306
+ */
307
+ sidebar_position?: number;
308
+ /**
309
+ * Gives the corresponding sidebar label a special class name when using
310
+ * autogenerated sidebars.
311
+ */
312
+ sidebar_class_name?: string;
313
+ /**
314
+ * Will be propagated to the final sidebars data structure. Useful if you
315
+ * have swizzled sidebar-related code or simply querying doc data through
316
+ * sidebars.
317
+ */
318
+ sidebar_custom_props?: {[key: string]: unknown};
319
+ /**
320
+ * Changes the sidebar association of the current doc. Use `null` to make
321
+ * the current doc not associated to any sidebar.
322
+ */
323
+ displayed_sidebar?: string | null;
324
+ /**
325
+ * Customizes the pagination label for this doc. Will default to the sidebar
326
+ * label.
327
+ */
328
+ pagination_label?: string;
329
+ /** Overrides the default URL computed for this doc. */
330
+ custom_edit_url?: string | null;
331
+ /**
332
+ * Whether number prefix parsing is disabled on this doc.
333
+ * @see https://docusaurus.io/docs/sidebar#using-number-prefixes
334
+ */
335
+ parse_number_prefixes?: boolean;
336
+ /**
337
+ * Minimum TOC heading level. Must be between 2 and 6 and lower or equal to
338
+ * the max value.
339
+ */
340
+ toc_min_heading_level?: number;
341
+ /** Maximum TOC heading level. Must be between 2 and 6. */
342
+ toc_max_heading_level?: number;
343
+ /**
344
+ * The ID of the documentation you want the "Next" pagination to link to.
345
+ * Use `null` to disable showing "Next" for this page.
346
+ * @see {@link DocMetadata.next}
347
+ */
348
+ pagination_next?: string | null;
349
+ /**
350
+ * The ID of the documentation you want the "Previous" pagination to link
351
+ * to. Use `null` to disable showing "Previous" for this page.
352
+ * @see {@link DocMetadata.prev}
353
+ */
354
+ pagination_prev?: string | null;
355
+ /** Should this doc be excluded from production builds? */
356
+ draft?: boolean;
357
+ };
358
+
359
+ export type LastUpdateData = {
360
+ /** A timestamp in **seconds**, directly acquired from `git log`. */
361
+ lastUpdatedAt?: number;
362
+ /** `lastUpdatedAt` formatted as a date according to the current locale. */
363
+ formattedLastUpdatedAt?: string;
364
+ /** The author's name directly acquired from `git log`. */
365
+ lastUpdatedBy?: string;
366
+ };
367
+
368
+ export type DocMetadataBase = LastUpdateData & {
369
+ // TODO
370
+ /**
371
+ * Legacy versioned ID. Will be refactored in the future to be unversioned.
372
+ */
373
+ id: string;
374
+ // TODO
375
+ /**
376
+ * Unversioned ID. Should be preferred everywhere over `id` until the latter
377
+ * is refactored.
378
+ */
379
+ unversionedId: string;
380
+ /** The name of the version this doc belongs to. */
381
+ version: string;
382
+ /**
383
+ * Used to generate the page h1 heading, tab title, and pagination title.
384
+ */
385
+ title: string;
386
+ /**
387
+ * Description used in the meta. Could be an empty string (empty content)
388
+ */
389
+ description: string;
390
+ /** Path to the Markdown source, with `@site` alias. */
391
+ source: string;
392
+ /**
393
+ * Posix path relative to the content path. Can be `"."`.
394
+ * e.g. "folder/subfolder/subsubfolder"
395
+ */
396
+ sourceDirName: string;
397
+ /** `permalink` without base URL or version path. */
398
+ slug: string;
399
+ /** Full URL to this doc, with base URL and version path. */
400
+ permalink: string;
401
+ /**
402
+ * Draft docs will be excluded for production environment.
403
+ */
404
+ draft: boolean;
405
+ /**
406
+ * Position in an autogenerated sidebar slice, acquired through front matter
407
+ * or number prefix.
408
+ */
409
+ sidebarPosition?: number;
410
+ /**
411
+ * Acquired from the options; can be customized with front matter.
412
+ * `custom_edit_url` will always lead to it being null, but you should treat
413
+ * `undefined` and `null` as equivalent.
414
+ */
415
+ editUrl?: string | null;
416
+ /** Tags, normalized. */
417
+ tags: Tag[];
418
+ /** Front matter, as-is. */
419
+ frontMatter: DocFrontMatter & {[key: string]: unknown};
420
+ };
421
+
422
+ export type DocMetadata = DocMetadataBase &
423
+ PropNavigation & {
424
+ /** Name of the sidebar this doc is associated with. */
425
+ sidebar?: string;
426
+ };
427
+
428
+ export type CategoryGeneratedIndexMetadata = Required<
429
+ Omit<
430
+ import('./sidebars/types').SidebarItemCategoryLinkGeneratedIndex,
431
+ 'type'
432
+ >,
433
+ 'title'
434
+ > & {
435
+ navigation: PropNavigation;
436
+ /**
437
+ * Name of the sidebar this doc is associated with. Unlike
438
+ * `DocMetadata.sidebar`, this will always be defined, because a generated
439
+ * index can only be generated from a category.
440
+ */
441
+ sidebar: string;
442
+ };
443
+
101
444
  export type PropNavigationLink = {
102
445
  readonly title: string;
103
446
  readonly permalink: string;
104
447
  };
105
448
  export type PropNavigation = {
449
+ /**
450
+ * Used in pagination. Content is just a subset of another doc's metadata.
451
+ */
106
452
  readonly previous?: PropNavigationLink;
453
+ /**
454
+ * Used in pagination. Content is just a subset of another doc's metadata.
455
+ */
107
456
  readonly next?: PropNavigationLink;
108
457
  };
109
458
 
110
- export type PropVersionDoc = import('./sidebars/types').PropVersionDoc;
111
- export type PropVersionDocs = import('./sidebars/types').PropVersionDocs;
459
+ export type PropVersionDoc = Pick<
460
+ DocMetadata,
461
+ 'id' | 'title' | 'description' | 'sidebar'
462
+ >;
112
463
 
113
- export type PropVersionMetadata = {
464
+ export type PropVersionDocs = {
465
+ [docId: string]: PropVersionDoc;
466
+ };
467
+
468
+ export type PropVersionMetadata = Pick<
469
+ VersionMetadata,
470
+ 'label' | 'banner' | 'badge' | 'className' | 'isLast'
471
+ > & {
472
+ /** ID of the docs plugin this version belongs to. */
114
473
  pluginId: string;
474
+ /** Name of this version. */
115
475
  version: string;
116
- label: string;
117
- banner: VersionBanner | null;
118
- badge: boolean;
119
- className: string;
120
- isLast: boolean;
476
+ /** Sidebars contained in this version. */
121
477
  docsSidebars: PropSidebars;
478
+ /** Docs contained in this version. */
122
479
  docs: PropVersionDocs;
123
480
  };
124
481
 
125
- export type PropCategoryGeneratedIndex = {
126
- title: string;
127
- description?: string;
128
- image?: string;
129
- keywords?: string | readonly string[];
130
- slug: string;
131
- permalink: string;
132
- navigation: PropNavigation;
133
- };
482
+ export type PropCategoryGeneratedIndex = Omit<
483
+ CategoryGeneratedIndexMetadata,
484
+ 'sidebar'
485
+ >;
134
486
 
135
487
  export type PropSidebarItemLink =
136
488
  import('./sidebars/types').PropSidebarItemLink;
489
+ export type PropSidebarItemHtml =
490
+ import('./sidebars/types').PropSidebarItemHtml;
137
491
  export type PropSidebarItemCategory =
138
492
  import('./sidebars/types').PropSidebarItemCategory;
139
493
  export type PropSidebarItem = import('./sidebars/types').PropSidebarItem;
@@ -142,34 +496,39 @@ declare module '@docusaurus/plugin-content-docs' {
142
496
  export type PropSidebar = import('./sidebars/types').PropSidebar;
143
497
  export type PropSidebars = import('./sidebars/types').PropSidebars;
144
498
 
145
- export type PropTagDocListDoc = {
146
- id: string;
147
- title: string;
148
- description: string;
149
- permalink: string;
499
+ export type PropTagDocListDoc = Pick<
500
+ DocMetadata,
501
+ 'id' | 'title' | 'description' | 'permalink'
502
+ >;
503
+ export type PropTagDocList = TagModule & {items: PropTagDocListDoc[]};
504
+
505
+ export type PropTagsListPage = {
506
+ tags: TagsListItem[];
150
507
  };
151
- export type PropTagDocList = {
152
- allTagsPath: string;
153
- name: string; // normalized name/label of the tag
154
- permalink: string; // pathname of the tag
155
- docs: PropTagDocListDoc[];
508
+
509
+ export type LoadedVersion = VersionMetadata & {
510
+ docs: DocMetadata[];
511
+ drafts: DocMetadata[];
512
+ sidebars: import('./sidebars/types').Sidebars;
156
513
  };
157
514
 
158
- export type PropTagsListPage = {
159
- tags: {
160
- name: string;
161
- permalink: string;
162
- count: number;
163
- }[];
515
+ export type LoadedContent = {
516
+ loadedVersions: LoadedVersion[];
164
517
  };
518
+
519
+ export default function pluginContentDocs(
520
+ context: LoadContext,
521
+ options: PluginOptions,
522
+ ): Promise<Plugin<LoadedContent>>;
165
523
  }
166
524
 
167
525
  declare module '@theme/DocItem' {
168
- import type {TOCItem} from '@docusaurus/types';
526
+ import type {LoadedMDXContent} from '@docusaurus/mdx-loader';
169
527
  import type {
170
- PropNavigationLink,
171
528
  PropVersionMetadata,
172
529
  Assets,
530
+ DocMetadata,
531
+ DocFrontMatter,
173
532
  } from '@docusaurus/plugin-content-docs';
174
533
 
175
534
  export type DocumentRoute = {
@@ -179,46 +538,10 @@ declare module '@theme/DocItem' {
179
538
  readonly sidebar?: string;
180
539
  };
181
540
 
182
- export type FrontMatter = {
183
- readonly id: string;
184
- readonly title: string;
185
- readonly image?: string;
186
- readonly keywords?: readonly string[];
187
- readonly hide_title?: boolean;
188
- readonly hide_table_of_contents?: boolean;
189
- readonly toc_min_heading_level?: number;
190
- readonly toc_max_heading_level?: number;
191
- };
192
-
193
- export type Metadata = {
194
- readonly unversionedId?: string;
195
- readonly description?: string;
196
- readonly title?: string;
197
- readonly permalink?: string;
198
- readonly editUrl?: string;
199
- readonly lastUpdatedAt?: number;
200
- readonly formattedLastUpdatedAt?: string;
201
- readonly lastUpdatedBy?: string;
202
- readonly version?: string;
203
- readonly previous?: PropNavigationLink;
204
- readonly next?: PropNavigationLink;
205
- readonly tags: readonly {
206
- readonly label: string;
207
- readonly permalink: string;
208
- }[];
209
- };
210
-
211
541
  export interface Props {
212
542
  readonly route: DocumentRoute;
213
543
  readonly versionMetadata: PropVersionMetadata;
214
- readonly content: {
215
- readonly frontMatter: FrontMatter;
216
- readonly metadata: Metadata;
217
- readonly toc: readonly TOCItem[];
218
- readonly contentTitle: string | undefined;
219
- readonly assets: Assets;
220
- (): JSX.Element;
221
- };
544
+ readonly content: LoadedMDXContent<DocFrontMatter, DocMetadata, Assets>;
222
545
  }
223
546
 
224
547
  export default function DocItem(props: Props): JSX.Element;
@@ -258,23 +581,21 @@ declare module '@theme/DocBreadcrumbs' {
258
581
 
259
582
  declare module '@theme/DocPage' {
260
583
  import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs';
261
- import type {DocumentRoute} from '@theme/DocItem';
584
+ import type {RouteConfigComponentProps} from 'react-router-config';
585
+ import type {Required} from 'utility-types';
262
586
 
263
- export interface Props {
264
- readonly location: {readonly pathname: string};
587
+ export interface Props extends Required<RouteConfigComponentProps, 'route'> {
265
588
  readonly versionMetadata: PropVersionMetadata;
266
- readonly route: {
267
- readonly path: string;
268
- readonly component: () => JSX.Element;
269
- readonly routes: DocumentRoute[];
270
- };
271
589
  }
272
590
 
273
591
  export default function DocPage(props: Props): JSX.Element;
274
592
  }
275
593
 
276
- // TODO until TS supports exports field... hope it's in 4.6
594
+ // TODO TS only supports reading `exports` in 4.7. We will need to merge the
595
+ // type defs (and JSDoc) here with the implementation after that
277
596
  declare module '@docusaurus/plugin-content-docs/client' {
597
+ import type {UseDataOptions} from '@docusaurus/types';
598
+
278
599
  export type ActivePlugin = {
279
600
  pluginId: string;
280
601
  pluginData: GlobalPluginData;
@@ -285,6 +606,11 @@ declare module '@docusaurus/plugin-content-docs/client' {
285
606
  alternateDocVersions: {[versionName: string]: GlobalDoc};
286
607
  };
287
608
  export type GlobalDoc = {
609
+ /**
610
+ * For generated index pages, this is the `slug`, **not** `permalink`
611
+ * (without base URL). Because slugs have leading slashes but IDs don't,
612
+ * there won't be clashes.
613
+ */
288
614
  id: string;
289
615
  path: string;
290
616
  sidebar: string | undefined;
@@ -295,18 +621,19 @@ declare module '@docusaurus/plugin-content-docs/client' {
295
621
  label: string;
296
622
  isLast: boolean;
297
623
  path: string;
298
- mainDocId: string; // home doc (if docs homepage configured), or first doc
624
+ /** The doc with `slug: /`, or first doc in first sidebar */
625
+ mainDocId: string;
299
626
  docs: GlobalDoc[];
627
+ /** Unversioned IDs. In development, this list is empty. */
628
+ draftIds: string[];
300
629
  sidebars?: {[sidebarId: string]: GlobalSidebar};
301
630
  };
302
631
 
303
- export type GlobalSidebarLink = {
304
- label: string;
305
- path: string;
306
- };
307
-
308
632
  export type GlobalSidebar = {
309
- link?: GlobalSidebarLink;
633
+ link?: {
634
+ label: string;
635
+ path: string;
636
+ };
310
637
  // ... we may add other things here later
311
638
  };
312
639
  export type GlobalPluginData = {
@@ -315,29 +642,36 @@ declare module '@docusaurus/plugin-content-docs/client' {
315
642
  breadcrumbs: boolean;
316
643
  };
317
644
  export type DocVersionSuggestions = {
318
- // suggest the latest version
645
+ /** Suggest the latest version */
319
646
  latestVersionSuggestion: GlobalVersion;
320
- // suggest the same doc, in latest version (if exist)
647
+ /** Suggest the same doc, in latest version (if one exists) */
321
648
  latestDocSuggestion?: GlobalDoc;
322
649
  };
323
- export type GetActivePluginOptions = {failfast?: boolean}; // use fail-fast option if you know for sure one plugin instance is active
324
650
 
325
651
  export const useAllDocsData: () => {[pluginId: string]: GlobalPluginData};
326
652
  export const useDocsData: (pluginId?: string) => GlobalPluginData;
327
653
  export const useActivePlugin: (
328
- options?: GetActivePluginOptions,
654
+ options?: UseDataOptions,
329
655
  ) => ActivePlugin | undefined;
330
656
  export const useActivePluginAndVersion: (
331
- options?: GetActivePluginOptions,
657
+ options?: UseDataOptions,
332
658
  ) =>
333
659
  | {activePlugin: ActivePlugin; activeVersion: GlobalVersion | undefined}
334
660
  | undefined;
661
+ /** Versions are returned ordered (most recent first). */
335
662
  export const useVersions: (pluginId?: string) => GlobalVersion[];
336
663
  export const useLatestVersion: (pluginId?: string) => GlobalVersion;
664
+ /**
665
+ * Returns `undefined` on doc-unrelated pages, because there's no version
666
+ * currently considered as active.
667
+ */
337
668
  export const useActiveVersion: (
338
669
  pluginId?: string,
339
670
  ) => GlobalVersion | undefined;
340
671
  export const useActiveDocContext: (pluginId?: string) => ActiveDocContext;
672
+ /**
673
+ * Useful to say "hey, you are not on the latest docs version, please switch"
674
+ */
341
675
  export const useDocVersionSuggestions: (
342
676
  pluginId?: string,
343
677
  ) => DocVersionSuggestions;