@docusaurus/plugin-content-docs 2.0.0-beta.16 → 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 (93) hide show
  1. package/lib/categoryGeneratedIndex.d.ts +1 -1
  2. package/lib/categoryGeneratedIndex.js +5 -7
  3. package/lib/cli.d.ts +3 -2
  4. package/lib/cli.js +49 -41
  5. package/lib/client/docsClientUtils.d.ts +8 -5
  6. package/lib/client/docsClientUtils.js +13 -15
  7. package/lib/client/index.d.ts +12 -9
  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 +8 -15
  12. package/lib/docs.js +34 -39
  13. package/lib/{docFrontMatter.d.ts → frontMatter.d.ts} +4 -2
  14. package/lib/{docFrontMatter.js → frontMatter.js} +3 -0
  15. package/lib/globalData.d.ts +3 -7
  16. package/lib/globalData.js +9 -13
  17. package/lib/index.d.ts +1 -2
  18. package/lib/index.js +33 -26
  19. package/lib/lastUpdate.d.ts +4 -6
  20. package/lib/lastUpdate.js +14 -5
  21. package/lib/markdown/index.js +1 -1
  22. package/lib/markdown/linkify.js +5 -2
  23. package/lib/numberPrefix.js +16 -22
  24. package/lib/options.d.ts +3 -5
  25. package/lib/options.js +6 -5
  26. package/lib/props.d.ts +3 -3
  27. package/lib/props.js +10 -10
  28. package/lib/routes.d.ts +5 -4
  29. package/lib/routes.js +10 -24
  30. package/lib/server-export.d.ts +2 -1
  31. package/lib/server-export.js +3 -4
  32. package/lib/sidebars/generator.js +63 -44
  33. package/lib/sidebars/index.js +20 -16
  34. package/lib/sidebars/normalization.js +3 -3
  35. package/lib/sidebars/postProcessor.js +18 -25
  36. package/lib/sidebars/processor.d.ts +3 -1
  37. package/lib/sidebars/processor.js +17 -6
  38. package/lib/sidebars/types.d.ts +31 -19
  39. package/lib/sidebars/utils.d.ts +17 -6
  40. package/lib/sidebars/utils.js +27 -37
  41. package/lib/sidebars/validation.d.ts +3 -1
  42. package/lib/sidebars/validation.js +1 -0
  43. package/lib/slug.d.ts +1 -2
  44. package/lib/slug.js +4 -5
  45. package/lib/tags.d.ts +2 -1
  46. package/lib/tags.js +2 -2
  47. package/lib/translations.d.ts +3 -3
  48. package/lib/translations.js +28 -81
  49. package/lib/types.d.ts +10 -95
  50. package/lib/versions/files.d.ts +44 -0
  51. package/lib/versions/files.js +142 -0
  52. package/lib/versions/index.d.ts +36 -0
  53. package/lib/versions/index.js +155 -0
  54. package/lib/versions/validation.d.ts +17 -0
  55. package/lib/versions/validation.js +71 -0
  56. package/package.json +14 -12
  57. package/src/categoryGeneratedIndex.ts +10 -9
  58. package/src/cli.ts +64 -69
  59. package/src/client/docsClientUtils.ts +14 -16
  60. package/src/client/index.ts +42 -43
  61. package/src/constants.ts +4 -2
  62. package/src/deps.d.ts +1 -1
  63. package/src/docs.ts +48 -51
  64. package/src/{docFrontMatter.ts → frontMatter.ts} +9 -6
  65. package/src/globalData.ts +15 -16
  66. package/src/index.ts +45 -40
  67. package/src/lastUpdate.ts +20 -8
  68. package/src/markdown/index.ts +1 -3
  69. package/src/markdown/linkify.ts +6 -3
  70. package/src/numberPrefix.ts +18 -28
  71. package/src/options.ts +6 -8
  72. package/src/plugin-content-docs.d.ts +457 -116
  73. package/src/props.ts +12 -9
  74. package/src/routes.ts +13 -39
  75. package/src/server-export.ts +1 -3
  76. package/src/sidebars/generator.ts +88 -59
  77. package/src/sidebars/index.ts +20 -15
  78. package/src/sidebars/normalization.ts +1 -1
  79. package/src/sidebars/postProcessor.ts +6 -11
  80. package/src/sidebars/processor.ts +27 -14
  81. package/src/sidebars/types.ts +25 -23
  82. package/src/sidebars/utils.ts +45 -46
  83. package/src/sidebars/validation.ts +4 -3
  84. package/src/slug.ts +7 -6
  85. package/src/tags.ts +3 -2
  86. package/src/translations.ts +32 -84
  87. package/src/types.ts +15 -107
  88. package/src/versions/files.ts +220 -0
  89. package/src/versions/index.ts +247 -0
  90. package/src/versions/validation.ts +113 -0
  91. package/lib/versions.d.ts +0 -41
  92. package/lib/versions.js +0 -329
  93. package/src/versions.ts +0 -606
@@ -6,128 +6,488 @@
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: {
35
+ /** The file name, without extension */
21
36
  fileName: string;
37
+ /**
38
+ * The list of directories, from lowest level to highest.
39
+ * If there's no dir name, directories is ['.']
40
+ */
22
41
  directories: string[];
42
+ /** The extension, with a leading dot */
23
43
  extension: string;
24
- };
25
- export type CategoryIndexMatcher = (
26
- param: CategoryIndexMatcherParam,
27
- ) => boolean;
44
+ }) => boolean;
28
45
 
29
46
  export type EditUrlFunction = (editUrlParams: {
47
+ /** Name of the version. */
30
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
+ */
31
53
  versionDocsDirPath: string;
54
+ /** Path of the doc file, relative to `versionDocsDirPath`. */
32
55
  docPath: string;
56
+ /** @see {@link DocMetadata.permalink} */
33
57
  permalink: string;
58
+ /** Locale name. */
34
59
  locale: string;
35
60
  }) => string | undefined;
36
61
 
37
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
+ */
38
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
+ */
39
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
+ */
40
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
+ */
41
83
  editLocalizedFiles: boolean;
84
+ /** Whether to display the last date the doc was updated. */
42
85
  showLastUpdateTime?: boolean;
86
+ /** Whether to display the author who last updated the doc. */
43
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
+ */
44
96
  numberPrefixParser: NumberPrefixParser;
97
+ /** Enable or disable the breadcrumbs on doc pages. */
45
98
  breadcrumbs: boolean;
46
99
  };
47
100
 
48
101
  export type PathOptions = {
102
+ /**
103
+ * Path to the docs content directory on the file system, relative to site
104
+ * directory.
105
+ */
49
106
  path: string;
107
+ /**
108
+ * Path to sidebar configuration. Use `false` to disable sidebars, or
109
+ * `undefined` to create a fully autogenerated sidebar.
110
+ */
50
111
  sidebarPath?: string | false | undefined;
51
112
  };
52
113
 
53
114
  // TODO support custom version banner?
54
115
  // {type: "error", content: "html content"}
55
116
  export type VersionBanner = 'unreleased' | 'unmaintained';
56
- export type VersionOptions = {
57
- path?: string;
58
- label?: string;
59
- banner?: 'none' | VersionBanner;
60
- badge?: boolean;
61
- className?: string;
62
- };
63
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
+ */
64
124
  lastVersion?: string;
65
- versions: Record<string, VersionOptions>;
125
+ /** Only include a subset of all available versions. */
66
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
+ };
67
153
  };
68
154
  export type SidebarOptions = {
155
+ /**
156
+ * Whether sidebar categories are collapsible by default.
157
+ *
158
+ * @see https://docusaurus.io/docs/sidebar#collapsible-categories
159
+ */
69
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
+ */
70
166
  sidebarCollapsed: boolean;
71
167
  };
72
168
 
73
169
  export type PluginOptions = MetadataOptions &
74
170
  PathOptions &
75
171
  VersionsOptions &
76
- RemarkAndRehypePluginOptions &
172
+ MDXOptions &
77
173
  SidebarOptions & {
174
+ /** Plugin ID. */
78
175
  id: string;
176
+ /**
177
+ * Array of glob patterns matching Markdown files to be built, relative to
178
+ * the content path.
179
+ */
79
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
+ */
80
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
+ */
81
190
  docLayoutComponent: string;
191
+ /** Main doc container, with TOC, pagination, etc. */
82
192
  docItemComponent: string;
193
+ /** Root component of the "docs containing tag X" page. */
83
194
  docTagDocListComponent: string;
195
+ /** Root component of the tags list page */
84
196
  docTagsListComponent: string;
197
+ /** Root component of the generated category index page. */
85
198
  docCategoryGeneratedIndexComponent: string;
86
- admonitions: Record<string, unknown>;
87
- disableVersioning: boolean;
88
- includeCurrentVersion: boolean;
199
+ admonitions: {[key: string]: unknown};
89
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
+ */
90
205
  tagsBasePath: string;
91
206
  };
92
207
  export type Options = Partial<PluginOptions>;
93
208
  export type SidebarsConfig = import('./sidebars/types').SidebarsConfig;
94
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
+
95
444
  export type PropNavigationLink = {
96
445
  readonly title: string;
97
446
  readonly permalink: string;
98
447
  };
99
448
  export type PropNavigation = {
449
+ /**
450
+ * Used in pagination. Content is just a subset of another doc's metadata.
451
+ */
100
452
  readonly previous?: PropNavigationLink;
453
+ /**
454
+ * Used in pagination. Content is just a subset of another doc's metadata.
455
+ */
101
456
  readonly next?: PropNavigationLink;
102
457
  };
103
458
 
104
- export type PropVersionDoc = import('./sidebars/types').PropVersionDoc;
105
- export type PropVersionDocs = import('./sidebars/types').PropVersionDocs;
459
+ export type PropVersionDoc = Pick<
460
+ DocMetadata,
461
+ 'id' | 'title' | 'description' | 'sidebar'
462
+ >;
463
+
464
+ export type PropVersionDocs = {
465
+ [docId: string]: PropVersionDoc;
466
+ };
106
467
 
107
- export type PropVersionMetadata = {
468
+ export type PropVersionMetadata = Pick<
469
+ VersionMetadata,
470
+ 'label' | 'banner' | 'badge' | 'className' | 'isLast'
471
+ > & {
472
+ /** ID of the docs plugin this version belongs to. */
108
473
  pluginId: string;
474
+ /** Name of this version. */
109
475
  version: string;
110
- label: string;
111
- banner: VersionBanner | null;
112
- badge: boolean;
113
- className: string;
114
- isLast: boolean;
476
+ /** Sidebars contained in this version. */
115
477
  docsSidebars: PropSidebars;
478
+ /** Docs contained in this version. */
116
479
  docs: PropVersionDocs;
117
480
  };
118
481
 
119
- export type PropCategoryGeneratedIndex = {
120
- title: string;
121
- description?: string;
122
- image?: string;
123
- keywords?: string | readonly string[];
124
- slug: string;
125
- permalink: string;
126
- navigation: PropNavigation;
127
- };
482
+ export type PropCategoryGeneratedIndex = Omit<
483
+ CategoryGeneratedIndexMetadata,
484
+ 'sidebar'
485
+ >;
128
486
 
129
487
  export type PropSidebarItemLink =
130
488
  import('./sidebars/types').PropSidebarItemLink;
489
+ export type PropSidebarItemHtml =
490
+ import('./sidebars/types').PropSidebarItemHtml;
131
491
  export type PropSidebarItemCategory =
132
492
  import('./sidebars/types').PropSidebarItemCategory;
133
493
  export type PropSidebarItem = import('./sidebars/types').PropSidebarItem;
@@ -136,34 +496,39 @@ declare module '@docusaurus/plugin-content-docs' {
136
496
  export type PropSidebar = import('./sidebars/types').PropSidebar;
137
497
  export type PropSidebars = import('./sidebars/types').PropSidebars;
138
498
 
139
- export type PropTagDocListDoc = {
140
- id: string;
141
- title: string;
142
- description: string;
143
- 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[];
144
507
  };
145
- export type PropTagDocList = {
146
- allTagsPath: string;
147
- name: string; // normalized name/label of the tag
148
- permalink: string; // pathname of the tag
149
- docs: PropTagDocListDoc[];
508
+
509
+ export type LoadedVersion = VersionMetadata & {
510
+ docs: DocMetadata[];
511
+ drafts: DocMetadata[];
512
+ sidebars: import('./sidebars/types').Sidebars;
150
513
  };
151
514
 
152
- export type PropTagsListPage = {
153
- tags: {
154
- name: string;
155
- permalink: string;
156
- count: number;
157
- }[];
515
+ export type LoadedContent = {
516
+ loadedVersions: LoadedVersion[];
158
517
  };
518
+
519
+ export default function pluginContentDocs(
520
+ context: LoadContext,
521
+ options: PluginOptions,
522
+ ): Promise<Plugin<LoadedContent>>;
159
523
  }
160
524
 
161
525
  declare module '@theme/DocItem' {
162
- import type {TOCItem} from '@docusaurus/types';
526
+ import type {LoadedMDXContent} from '@docusaurus/mdx-loader';
163
527
  import type {
164
- PropNavigationLink,
165
528
  PropVersionMetadata,
166
529
  Assets,
530
+ DocMetadata,
531
+ DocFrontMatter,
167
532
  } from '@docusaurus/plugin-content-docs';
168
533
 
169
534
  export type DocumentRoute = {
@@ -173,45 +538,10 @@ declare module '@theme/DocItem' {
173
538
  readonly sidebar?: string;
174
539
  };
175
540
 
176
- export type FrontMatter = {
177
- readonly id: string;
178
- readonly title: string;
179
- readonly image?: string;
180
- readonly keywords?: readonly string[];
181
- readonly hide_title?: boolean;
182
- readonly hide_table_of_contents?: boolean;
183
- readonly toc_min_heading_level?: number;
184
- readonly toc_max_heading_level?: number;
185
- };
186
-
187
- export type Metadata = {
188
- readonly description?: string;
189
- readonly title?: string;
190
- readonly permalink?: string;
191
- readonly editUrl?: string;
192
- readonly lastUpdatedAt?: number;
193
- readonly formattedLastUpdatedAt?: string;
194
- readonly lastUpdatedBy?: string;
195
- readonly version?: string;
196
- readonly previous?: PropNavigationLink;
197
- readonly next?: PropNavigationLink;
198
- readonly tags: readonly {
199
- readonly label: string;
200
- readonly permalink: string;
201
- }[];
202
- };
203
-
204
541
  export interface Props {
205
542
  readonly route: DocumentRoute;
206
543
  readonly versionMetadata: PropVersionMetadata;
207
- readonly content: {
208
- readonly frontMatter: FrontMatter;
209
- readonly metadata: Metadata;
210
- readonly toc: readonly TOCItem[];
211
- readonly contentTitle: string | undefined;
212
- readonly assets: Assets;
213
- (): JSX.Element;
214
- };
544
+ readonly content: LoadedMDXContent<DocFrontMatter, DocMetadata, Assets>;
215
545
  }
216
546
 
217
547
  export default function DocItem(props: Props): JSX.Element;
@@ -251,23 +581,21 @@ declare module '@theme/DocBreadcrumbs' {
251
581
 
252
582
  declare module '@theme/DocPage' {
253
583
  import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs';
254
- import type {DocumentRoute} from '@theme/DocItem';
584
+ import type {RouteConfigComponentProps} from 'react-router-config';
585
+ import type {Required} from 'utility-types';
255
586
 
256
- export interface Props {
257
- readonly location: {readonly pathname: string};
587
+ export interface Props extends Required<RouteConfigComponentProps, 'route'> {
258
588
  readonly versionMetadata: PropVersionMetadata;
259
- readonly route: {
260
- readonly path: string;
261
- readonly component: () => JSX.Element;
262
- readonly routes: DocumentRoute[];
263
- };
264
589
  }
265
590
 
266
591
  export default function DocPage(props: Props): JSX.Element;
267
592
  }
268
593
 
269
- // 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
270
596
  declare module '@docusaurus/plugin-content-docs/client' {
597
+ import type {UseDataOptions} from '@docusaurus/types';
598
+
271
599
  export type ActivePlugin = {
272
600
  pluginId: string;
273
601
  pluginData: GlobalPluginData;
@@ -275,9 +603,14 @@ declare module '@docusaurus/plugin-content-docs/client' {
275
603
  export type ActiveDocContext = {
276
604
  activeVersion?: GlobalVersion;
277
605
  activeDoc?: GlobalDoc;
278
- alternateDocVersions: Record<string, GlobalDoc>;
606
+ alternateDocVersions: {[versionName: string]: GlobalDoc};
279
607
  };
280
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
+ */
281
614
  id: string;
282
615
  path: string;
283
616
  sidebar: string | undefined;
@@ -288,18 +621,19 @@ declare module '@docusaurus/plugin-content-docs/client' {
288
621
  label: string;
289
622
  isLast: boolean;
290
623
  path: string;
291
- 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;
292
626
  docs: GlobalDoc[];
293
- sidebars?: Record<string, GlobalSidebar>;
294
- };
295
-
296
- export type GlobalSidebarLink = {
297
- label: string;
298
- path: string;
627
+ /** Unversioned IDs. In development, this list is empty. */
628
+ draftIds: string[];
629
+ sidebars?: {[sidebarId: string]: GlobalSidebar};
299
630
  };
300
631
 
301
632
  export type GlobalSidebar = {
302
- link?: GlobalSidebarLink;
633
+ link?: {
634
+ label: string;
635
+ path: string;
636
+ };
303
637
  // ... we may add other things here later
304
638
  };
305
639
  export type GlobalPluginData = {
@@ -308,29 +642,36 @@ declare module '@docusaurus/plugin-content-docs/client' {
308
642
  breadcrumbs: boolean;
309
643
  };
310
644
  export type DocVersionSuggestions = {
311
- // suggest the latest version
645
+ /** Suggest the latest version */
312
646
  latestVersionSuggestion: GlobalVersion;
313
- // suggest the same doc, in latest version (if exist)
647
+ /** Suggest the same doc, in latest version (if one exists) */
314
648
  latestDocSuggestion?: GlobalDoc;
315
649
  };
316
- export type GetActivePluginOptions = {failfast?: boolean}; // use fail-fast option if you know for sure one plugin instance is active
317
650
 
318
- export const useAllDocsData: () => Record<string, GlobalPluginData>;
651
+ export const useAllDocsData: () => {[pluginId: string]: GlobalPluginData};
319
652
  export const useDocsData: (pluginId?: string) => GlobalPluginData;
320
653
  export const useActivePlugin: (
321
- options?: GetActivePluginOptions,
654
+ options?: UseDataOptions,
322
655
  ) => ActivePlugin | undefined;
323
656
  export const useActivePluginAndVersion: (
324
- options?: GetActivePluginOptions,
657
+ options?: UseDataOptions,
325
658
  ) =>
326
659
  | {activePlugin: ActivePlugin; activeVersion: GlobalVersion | undefined}
327
660
  | undefined;
661
+ /** Versions are returned ordered (most recent first). */
328
662
  export const useVersions: (pluginId?: string) => GlobalVersion[];
329
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
+ */
330
668
  export const useActiveVersion: (
331
669
  pluginId?: string,
332
670
  ) => GlobalVersion | undefined;
333
671
  export const useActiveDocContext: (pluginId?: string) => ActiveDocContext;
672
+ /**
673
+ * Useful to say "hey, you are not on the latest docs version, please switch"
674
+ */
334
675
  export const useDocVersionSuggestions: (
335
676
  pluginId?: string,
336
677
  ) => DocVersionSuggestions;