@docusaurus/plugin-content-docs 2.0.0-beta.fc64c12e4 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. package/lib/categoryGeneratedIndex.d.ts +12 -0
  2. package/lib/categoryGeneratedIndex.js +37 -0
  3. package/lib/cli.d.ts +3 -2
  4. package/lib/cli.js +57 -73
  5. package/lib/client/docsClientUtils.d.ts +9 -28
  6. package/lib/client/docsClientUtils.js +34 -43
  7. package/lib/client/index.d.ts +81 -0
  8. package/lib/client/index.js +67 -0
  9. package/lib/constants.d.ts +4 -0
  10. package/lib/constants.js +4 -1
  11. package/lib/docs.d.ts +33 -6
  12. package/lib/docs.js +201 -78
  13. package/{src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docusaurus.config.js → lib/frontMatter.d.ts} +4 -8
  14. package/lib/{docFrontMatter.js → frontMatter.js} +22 -3
  15. package/lib/globalData.d.ts +3 -3
  16. package/lib/globalData.js +35 -6
  17. package/lib/index.d.ts +3 -3
  18. package/lib/index.js +120 -153
  19. package/lib/lastUpdate.d.ts +4 -6
  20. package/lib/lastUpdate.js +22 -26
  21. package/lib/markdown/index.d.ts +3 -6
  22. package/lib/markdown/index.js +3 -3
  23. package/lib/markdown/linkify.d.ts +1 -1
  24. package/lib/markdown/linkify.js +6 -3
  25. package/lib/numberPrefix.d.ts +1 -1
  26. package/lib/numberPrefix.js +16 -21
  27. package/lib/options.d.ts +3 -5
  28. package/lib/options.js +34 -26
  29. package/lib/props.d.ts +7 -2
  30. package/lib/props.js +84 -13
  31. package/lib/routes.d.ts +29 -0
  32. package/lib/routes.js +96 -0
  33. package/lib/server-export.d.ts +9 -0
  34. package/lib/server-export.js +25 -0
  35. package/lib/{sidebarItemsGenerator.d.ts → sidebars/generator.d.ts} +1 -7
  36. package/lib/sidebars/generator.js +209 -0
  37. package/lib/sidebars/index.d.ts +13 -0
  38. package/lib/sidebars/index.js +92 -0
  39. package/lib/sidebars/normalization.d.ts +13 -0
  40. package/lib/sidebars/normalization.js +59 -0
  41. package/lib/sidebars/postProcessor.d.ts +11 -0
  42. package/lib/sidebars/postProcessor.js +81 -0
  43. package/lib/sidebars/processor.d.ts +10 -0
  44. package/lib/sidebars/processor.js +79 -0
  45. package/lib/sidebars/types.d.ts +183 -0
  46. package/lib/{docFrontMatter.d.ts → sidebars/types.js} +2 -2
  47. package/lib/sidebars/utils.d.ts +55 -0
  48. package/lib/sidebars/utils.js +259 -0
  49. package/lib/sidebars/validation.d.ts +11 -0
  50. package/lib/sidebars/validation.js +143 -0
  51. package/lib/slug.d.ts +5 -4
  52. package/lib/slug.js +28 -18
  53. package/{src/__tests__/__fixtures__/sidebars/sidebars-first-level-not-category.js → lib/tags.d.ts} +3 -14
  54. package/lib/tags.js +21 -0
  55. package/lib/translations.d.ts +3 -3
  56. package/lib/translations.js +100 -93
  57. package/lib/types.d.ts +13 -192
  58. package/lib/versions/files.d.ts +50 -0
  59. package/lib/versions/files.js +141 -0
  60. package/lib/versions/index.d.ts +36 -0
  61. package/lib/versions/index.js +154 -0
  62. package/lib/versions/validation.d.ts +17 -0
  63. package/lib/versions/validation.js +71 -0
  64. package/package.json +44 -30
  65. package/src/categoryGeneratedIndex.ts +60 -0
  66. package/src/cli.ts +88 -118
  67. package/src/client/docsClientUtils.ts +44 -71
  68. package/src/client/index.ts +158 -0
  69. package/src/constants.ts +4 -2
  70. package/src/docs.ts +277 -80
  71. package/src/frontMatter.ts +63 -0
  72. package/src/globalData.ts +57 -7
  73. package/src/index.ts +174 -221
  74. package/src/lastUpdate.ts +27 -38
  75. package/src/markdown/index.ts +10 -16
  76. package/src/markdown/linkify.ts +7 -4
  77. package/src/numberPrefix.ts +19 -26
  78. package/src/options.ts +38 -38
  79. package/src/plugin-content-docs.d.ts +570 -91
  80. package/src/props.ts +121 -20
  81. package/src/routes.ts +159 -0
  82. package/src/server-export.ts +26 -0
  83. package/src/sidebars/README.md +10 -0
  84. package/src/sidebars/generator.ts +292 -0
  85. package/src/sidebars/index.ts +118 -0
  86. package/src/sidebars/normalization.ts +91 -0
  87. package/src/sidebars/postProcessor.ts +112 -0
  88. package/src/sidebars/processor.ts +123 -0
  89. package/src/sidebars/types.ts +280 -0
  90. package/src/sidebars/utils.ts +393 -0
  91. package/src/sidebars/validation.ts +179 -0
  92. package/src/slug.ts +41 -22
  93. package/src/tags.ts +20 -0
  94. package/src/translations.ts +155 -124
  95. package/src/types.ts +17 -259
  96. package/src/versions/files.ts +216 -0
  97. package/src/versions/index.ts +246 -0
  98. package/src/versions/validation.ts +115 -0
  99. package/lib/.tsbuildinfo +0 -1
  100. package/lib/sidebarItemsGenerator.js +0 -215
  101. package/lib/sidebars.d.ts +0 -45
  102. package/lib/sidebars.js +0 -354
  103. package/lib/theme/hooks/useDocs.d.ts +0 -20
  104. package/lib/theme/hooks/useDocs.js +0 -75
  105. package/lib/versions.d.ts +0 -16
  106. package/lib/versions.js +0 -319
  107. package/src/__tests__/__fixtures__/bad-id-site/docs/invalid-id.md +0 -5
  108. package/src/__tests__/__fixtures__/bad-slug-on-doc-home-site/docs/docWithSlug.md +0 -5
  109. package/src/__tests__/__fixtures__/empty-site/docusaurus.config.js +0 -16
  110. package/src/__tests__/__fixtures__/empty-site/sidebars.json +0 -1
  111. package/src/__tests__/__fixtures__/sidebars/sidebars-category-shorthand.js +0 -34
  112. package/src/__tests__/__fixtures__/sidebars/sidebars-category-wrong-items.json +0 -11
  113. package/src/__tests__/__fixtures__/sidebars/sidebars-category-wrong-label.json +0 -11
  114. package/src/__tests__/__fixtures__/sidebars/sidebars-category.js +0 -44
  115. package/src/__tests__/__fixtures__/sidebars/sidebars-collapsed-first-level.json +0 -20
  116. package/src/__tests__/__fixtures__/sidebars/sidebars-collapsed.json +0 -21
  117. package/src/__tests__/__fixtures__/sidebars/sidebars-doc-id-not-string.json +0 -10
  118. package/src/__tests__/__fixtures__/sidebars/sidebars-link-wrong-href.json +0 -11
  119. package/src/__tests__/__fixtures__/sidebars/sidebars-link-wrong-label.json +0 -11
  120. package/src/__tests__/__fixtures__/sidebars/sidebars-link.json +0 -11
  121. package/src/__tests__/__fixtures__/sidebars/sidebars-unknown-type.json +0 -14
  122. package/src/__tests__/__fixtures__/sidebars/sidebars-wrong-field.json +0 -20
  123. package/src/__tests__/__fixtures__/sidebars/sidebars.json +0 -20
  124. package/src/__tests__/__fixtures__/simple-site/docs/_partials/somePartial.md +0 -3
  125. package/src/__tests__/__fixtures__/simple-site/docs/_partials/subfolder/somePartial.md +0 -3
  126. package/src/__tests__/__fixtures__/simple-site/docs/_somePartial.md +0 -3
  127. package/src/__tests__/__fixtures__/simple-site/docs/foo/bar.md +0 -69
  128. package/src/__tests__/__fixtures__/simple-site/docs/foo/baz.md +0 -70
  129. package/src/__tests__/__fixtures__/simple-site/docs/headingAsTitle.md +0 -1
  130. package/src/__tests__/__fixtures__/simple-site/docs/hello.md +0 -53
  131. package/src/__tests__/__fixtures__/simple-site/docs/ipsum.md +0 -5
  132. package/src/__tests__/__fixtures__/simple-site/docs/lorem.md +0 -6
  133. package/src/__tests__/__fixtures__/simple-site/docs/rootAbsoluteSlug.md +0 -5
  134. package/src/__tests__/__fixtures__/simple-site/docs/rootRelativeSlug.md +0 -5
  135. package/src/__tests__/__fixtures__/simple-site/docs/rootResolvedSlug.md +0 -5
  136. package/src/__tests__/__fixtures__/simple-site/docs/rootTryToEscapeSlug.md +0 -5
  137. package/src/__tests__/__fixtures__/simple-site/docs/slugs/absoluteSlug.md +0 -5
  138. package/src/__tests__/__fixtures__/simple-site/docs/slugs/relativeSlug.md +0 -5
  139. package/src/__tests__/__fixtures__/simple-site/docs/slugs/resolvedSlug.md +0 -5
  140. package/src/__tests__/__fixtures__/simple-site/docs/slugs/tryToEscapeSlug.md +0 -5
  141. package/src/__tests__/__fixtures__/simple-site/docusaurus.config.js +0 -14
  142. package/src/__tests__/__fixtures__/simple-site/sidebars.json +0 -23
  143. package/src/__tests__/__fixtures__/simple-site/wrong-sidebars.json +0 -7
  144. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/0-getting-started.md +0 -3
  145. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/1-installation.md +0 -3
  146. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/00_api-overview.md +0 -3
  147. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/01_Core APIs/0 --- Client API.md +0 -1
  148. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/01_Core APIs/1 --- Server API.md +0 -1
  149. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/02_Extension APIs/0. Plugin API.md +0 -1
  150. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/02_Extension APIs/1. Theme API.md +0 -1
  151. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/02_Extension APIs/_category_.yml +0 -1
  152. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/03_api-end.md +0 -3
  153. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/_category_.json +0 -3
  154. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/0-guide2.5.md +0 -8
  155. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/02-guide2.md +0 -7
  156. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/_category_.json +0 -3
  157. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/a-guide4.md +0 -7
  158. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/b-guide5.md +0 -7
  159. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/guide3.md +0 -8
  160. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/z-guide1.md +0 -8
  161. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/partialAutogeneratedSidebars.js +0 -23
  162. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/partialAutogeneratedSidebars2.js +0 -16
  163. package/src/__tests__/__fixtures__/site-with-doc-label/docs/hello-1.md +0 -7
  164. package/src/__tests__/__fixtures__/site-with-doc-label/docs/hello-2.md +0 -8
  165. package/src/__tests__/__fixtures__/site-with-doc-label/docusaurus.config.js +0 -14
  166. package/src/__tests__/__fixtures__/site-with-doc-label/sidebars.json +0 -14
  167. package/src/__tests__/__fixtures__/versioned-site/community/team.md +0 -1
  168. package/src/__tests__/__fixtures__/versioned-site/community_sidebars.json +0 -3
  169. package/src/__tests__/__fixtures__/versioned-site/community_versioned_docs/version-1.0.0/team.md +0 -1
  170. package/src/__tests__/__fixtures__/versioned-site/community_versioned_sidebars/version-1.0.0-sidebars.json +0 -3
  171. package/src/__tests__/__fixtures__/versioned-site/community_versions.json +0 -1
  172. package/src/__tests__/__fixtures__/versioned-site/docs/foo/bar.md +0 -4
  173. package/src/__tests__/__fixtures__/versioned-site/docs/hello.md +0 -1
  174. package/src/__tests__/__fixtures__/versioned-site/docs/slugs/absoluteSlug.md +0 -5
  175. package/src/__tests__/__fixtures__/versioned-site/docs/slugs/relativeSlug.md +0 -5
  176. package/src/__tests__/__fixtures__/versioned-site/docs/slugs/resolvedSlug.md +0 -5
  177. package/src/__tests__/__fixtures__/versioned-site/docs/slugs/tryToEscapeSlug.md +0 -5
  178. package/src/__tests__/__fixtures__/versioned-site/docusaurus.config.js +0 -18
  179. package/src/__tests__/__fixtures__/versioned-site/i18n/en/docusaurus-plugin-content-docs/version-1.0.0/hello.md +0 -1
  180. package/src/__tests__/__fixtures__/versioned-site/i18n/en/docusaurus-plugin-content-docs-community/current/team.md +0 -5
  181. package/src/__tests__/__fixtures__/versioned-site/i18n/fr/docusaurus-plugin-content-docs/version-1.0.0/hello.md +0 -1
  182. package/src/__tests__/__fixtures__/versioned-site/sidebars.json +0 -10
  183. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.0/foo/bar.md +0 -4
  184. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.0/foo/baz.md +0 -1
  185. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.0/hello.md +0 -1
  186. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/_partials/somePartial.md +0 -3
  187. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/_partials/subfolder/somePartial.md +0 -3
  188. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/_somePartial.md +0 -3
  189. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/foo/bar.md +0 -1
  190. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/hello.md +0 -1
  191. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootAbsoluteSlug.md +0 -5
  192. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootRelativeSlug.md +0 -5
  193. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootResolvedSlug.md +0 -5
  194. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootTryToEscapeSlug.md +0 -5
  195. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/absoluteSlug.md +0 -5
  196. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/relativeSlug.md +0 -5
  197. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/resolvedSlug.md +0 -5
  198. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/tryToEscapeSlug.md +0 -5
  199. package/src/__tests__/__fixtures__/versioned-site/versioned_sidebars/version-1.0.0-sidebars.json +0 -11
  200. package/src/__tests__/__fixtures__/versioned-site/versioned_sidebars/version-1.0.1-sidebars.json +0 -10
  201. package/src/__tests__/__fixtures__/versioned-site/versioned_sidebars/version-withSlugs-sidebars.json +0 -5
  202. package/src/__tests__/__fixtures__/versioned-site/versions.json +0 -5
  203. package/src/__tests__/__snapshots__/cli.test.ts.snap +0 -95
  204. package/src/__tests__/__snapshots__/index.test.ts.snap +0 -1926
  205. package/src/__tests__/__snapshots__/sidebars.test.ts.snap +0 -233
  206. package/src/__tests__/__snapshots__/translations.test.ts.snap +0 -484
  207. package/src/__tests__/cli.test.ts +0 -337
  208. package/src/__tests__/docFrontMatter.test.ts +0 -244
  209. package/src/__tests__/docs.test.ts +0 -878
  210. package/src/__tests__/index.test.ts +0 -1885
  211. package/src/__tests__/lastUpdate.test.ts +0 -69
  212. package/src/__tests__/numberPrefix.test.ts +0 -199
  213. package/src/__tests__/options.test.ts +0 -272
  214. package/src/__tests__/sidebarItemsGenerator.test.ts +0 -358
  215. package/src/__tests__/sidebars.test.ts +0 -746
  216. package/src/__tests__/slug.test.ts +0 -109
  217. package/src/__tests__/translations.test.ts +0 -158
  218. package/src/__tests__/versions.test.ts +0 -741
  219. package/src/client/__tests__/docsClientUtils.test.ts +0 -371
  220. package/src/docFrontMatter.ts +0 -41
  221. package/src/markdown/__tests__/__fixtures__/docs/doc-localized.md +0 -1
  222. package/src/markdown/__tests__/__fixtures__/docs/doc1.md +0 -13
  223. package/src/markdown/__tests__/__fixtures__/docs/doc2.md +0 -12
  224. package/src/markdown/__tests__/__fixtures__/docs/doc4.md +0 -19
  225. package/src/markdown/__tests__/__fixtures__/docs/doc5.md +0 -6
  226. package/src/markdown/__tests__/__fixtures__/docs/subdir/doc3.md +0 -3
  227. package/src/markdown/__tests__/__fixtures__/versioned_docs/version-1.0.0/doc2.md +0 -7
  228. package/src/markdown/__tests__/__fixtures__/versioned_docs/version-1.0.0/subdir/doc1.md +0 -3
  229. package/src/markdown/__tests__/__snapshots__/linkify.test.ts.snap +0 -82
  230. package/src/markdown/__tests__/linkify.test.ts +0 -190
  231. package/src/sidebarItemsGenerator.ts +0 -315
  232. package/src/sidebars.ts +0 -589
  233. package/src/theme/hooks/useDocs.ts +0 -103
  234. package/src/versions.ts +0 -572
  235. package/tsconfig.json +0 -9
  236. package/types.d.ts +0 -13
@@ -5,52 +5,558 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- /* eslint-disable camelcase */
8
+ /// <reference types="@docusaurus/module-type-aliases" />
9
9
 
10
- declare module '@docusaurus/plugin-content-docs-types' {
11
- type VersionBanner = import('./types').VersionBanner;
10
+ declare module '@docusaurus/plugin-content-docs' {
11
+ import type {MDXOptions, LoadedMDXContent} from '@docusaurus/mdx-loader';
12
12
 
13
- export type PropVersionMetadata = {
14
- pluginId: string;
13
+ import type {
14
+ ContentPaths,
15
+ FrontMatterTag,
16
+ TagsListItem,
17
+ TagModule,
18
+ Tag,
19
+ } from '@docusaurus/utils';
20
+ import type {Plugin, LoadContext} from '@docusaurus/types';
21
+ import type {Overwrite, Required} from 'utility-types';
22
+
23
+ export type Assets = {
24
+ image?: string;
25
+ };
26
+
27
+ export type FileChange = {
28
+ author?: string;
29
+ /** Date can be any
30
+ * [parsable date string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse).
31
+ */
32
+ date?: Date | string;
33
+ };
34
+
35
+ /**
36
+ * Custom callback for parsing number prefixes from file/folder names.
37
+ */
38
+ export type NumberPrefixParser = (filename: string) => {
39
+ /** File name without number prefix, without any other modification. */
40
+ filename: string;
41
+ /** The number prefix. Can be float, integer, negative, or anything. */
42
+ numberPrefix?: number;
43
+ };
44
+
45
+ export type CategoryIndexMatcher = (param: {
46
+ /** The file name, without extension */
47
+ fileName: string;
48
+ /**
49
+ * The list of directories, from lowest level to highest.
50
+ * If there's no dir name, directories is ['.']
51
+ */
52
+ directories: string[];
53
+ /** The extension, with a leading dot */
54
+ extension: string;
55
+ }) => boolean;
56
+
57
+ export type EditUrlFunction = (editUrlParams: {
58
+ /** Name of the version. */
15
59
  version: string;
60
+ /**
61
+ * Path of the version's root content path, relative to the site directory.
62
+ * Usually the same as `options.path` but can be localized or versioned.
63
+ */
64
+ versionDocsDirPath: string;
65
+ /** Path of the doc file, relative to `versionDocsDirPath`. */
66
+ docPath: string;
67
+ /** @see {@link DocMetadata.permalink} */
68
+ permalink: string;
69
+ /** Locale name. */
70
+ locale: string;
71
+ }) => string | undefined;
72
+
73
+ export type MetadataOptions = {
74
+ /**
75
+ * URL route for the docs section of your site. **DO NOT** include a
76
+ * trailing slash. Use `/` for shipping docs without base path.
77
+ */
78
+ routeBasePath: string;
79
+ /**
80
+ * Base URL to edit your site. The final URL is computed by `editUrl +
81
+ * relativeDocPath`. Using a function allows more nuanced control for each
82
+ * file. Omitting this variable entirely will disable edit links.
83
+ */
84
+ editUrl?: string | EditUrlFunction;
85
+ /**
86
+ * The edit URL will always target the current version doc instead of older
87
+ * versions. Ignored when `editUrl` is a function.
88
+ */
89
+ editCurrentVersion: boolean;
90
+ /**
91
+ * The edit URL will target the localized file, instead of the original
92
+ * unlocalized file. Ignored when `editUrl` is a function.
93
+ */
94
+ editLocalizedFiles: boolean;
95
+ /** Whether to display the last date the doc was updated. */
96
+ showLastUpdateTime?: boolean;
97
+ /** Whether to display the author who last updated the doc. */
98
+ showLastUpdateAuthor?: boolean;
99
+ /**
100
+ * Custom parsing logic to extract number prefixes from file names. Use
101
+ * `false` to disable this behavior and leave the docs untouched, and `true`
102
+ * to use the default parser.
103
+ *
104
+ * @param filename One segment of the path, without any slashes.
105
+ * @see https://docusaurus.io/docs/sidebar#using-number-prefixes
106
+ */
107
+ numberPrefixParser: NumberPrefixParser;
108
+ /** Enable or disable the breadcrumbs on doc pages. */
109
+ breadcrumbs: boolean;
110
+ };
111
+
112
+ export type PathOptions = {
113
+ /**
114
+ * Path to the docs content directory on the file system, relative to site
115
+ * directory.
116
+ */
117
+ path: string;
118
+ /**
119
+ * Path to sidebar configuration. Use `false` to disable sidebars, or
120
+ * `undefined` to create a fully autogenerated sidebar.
121
+ */
122
+ sidebarPath?: string | false | undefined;
123
+ };
124
+
125
+ // TODO support custom version banner?
126
+ // {type: "error", content: "html content"}
127
+ export type VersionBanner = 'unreleased' | 'unmaintained';
128
+ export type VersionsOptions = {
129
+ /**
130
+ * The version navigated to in priority and displayed by default for docs
131
+ * navbar items.
132
+ *
133
+ * @see https://docusaurus.io/docs/versioning#terminology
134
+ */
135
+ lastVersion?: string;
136
+ /** Only include a subset of all available versions. */
137
+ onlyIncludeVersions?: string[];
138
+ /**
139
+ * Explicitly disable versioning even when multiple versions exist. This
140
+ * will make the site only include the current version. Will error if
141
+ * `includeCurrentVersion: false` and `disableVersioning: true`.
142
+ */
143
+ disableVersioning: boolean;
144
+ /** Include the current version of your docs. */
145
+ includeCurrentVersion: boolean;
146
+ /** Independent customization of each version's properties. */
147
+ versions: {
148
+ [versionName: string]: {
149
+ /**
150
+ * The base path of the version, will be appended to `baseUrl` +
151
+ * `routeBasePath`.
152
+ */
153
+ path?: string;
154
+ /** The label of the version to be used in badges, dropdowns, etc. */
155
+ label?: string;
156
+ /** The banner to show at the top of a doc of that version. */
157
+ banner?: 'none' | VersionBanner;
158
+ /** Show a badge with the version label at the top of each doc. */
159
+ badge?: boolean;
160
+ /** Add a custom class name to the <html> element of each doc. */
161
+ className?: string;
162
+ };
163
+ };
164
+ };
165
+ export type SidebarOptions = {
166
+ /**
167
+ * Whether sidebar categories are collapsible by default.
168
+ *
169
+ * @see https://docusaurus.io/docs/sidebar#collapsible-categories
170
+ */
171
+ sidebarCollapsible: boolean;
172
+ /**
173
+ * Whether sidebar categories are collapsed by default.
174
+ *
175
+ * @see https://docusaurus.io/docs/sidebar#expanded-categories-by-default
176
+ */
177
+ sidebarCollapsed: boolean;
178
+ };
179
+
180
+ export type PluginOptions = MetadataOptions &
181
+ PathOptions &
182
+ VersionsOptions &
183
+ MDXOptions &
184
+ SidebarOptions & {
185
+ /** Plugin ID. */
186
+ id: string;
187
+ /**
188
+ * Array of glob patterns matching Markdown files to be built, relative to
189
+ * the content path.
190
+ */
191
+ include: string[];
192
+ /**
193
+ * Array of glob patterns matching Markdown files to be excluded. Serves
194
+ * as refinement based on the `include` option.
195
+ */
196
+ exclude: string[];
197
+ /**
198
+ * Root layout component of each doc page. Provides the version data
199
+ * context, and is not unmounted when switching docs.
200
+ */
201
+ docLayoutComponent: string;
202
+ /** Main doc container, with TOC, pagination, etc. */
203
+ docItemComponent: string;
204
+ /** Root component of the "docs containing tag X" page. */
205
+ docTagDocListComponent: string;
206
+ /** Root component of the tags list page */
207
+ docTagsListComponent: string;
208
+ /** Root component of the generated category index page. */
209
+ docCategoryGeneratedIndexComponent: string;
210
+ sidebarItemsGenerator: import('./sidebars/types').SidebarItemsGeneratorOption;
211
+ /**
212
+ * URL route for the tags section of your doc version. Will be appended to
213
+ * `routeBasePath`. **DO NOT** include a trailing slash.
214
+ */
215
+ tagsBasePath: string;
216
+ };
217
+ export type Options = Partial<
218
+ Overwrite<
219
+ PluginOptions,
220
+ {
221
+ /**
222
+ * Custom parsing logic to extract number prefixes from file names. Use
223
+ * `false` to disable this behavior and leave the docs untouched, and
224
+ * `true` to use the default parser.
225
+ *
226
+ * @param filename One segment of the path, without any slashes.
227
+ * @see https://docusaurus.io/docs/sidebar#using-number-prefixes
228
+ */
229
+ numberPrefixParser: PluginOptions['numberPrefixParser'] | boolean;
230
+ }
231
+ >
232
+ >;
233
+ export type SidebarsConfig = import('./sidebars/types').SidebarsConfig;
234
+
235
+ export type VersionMetadata = ContentPaths & {
236
+ /** A name like `1.0.0`. Acquired from `versions.json`. */
237
+ versionName: string;
238
+ /** Like `Version 1.0.0`. Can be configured through `versions.label`. */
16
239
  label: string;
17
- banner: VersionBanner;
240
+ /**
241
+ * Version's base path in the form of `/<baseUrl>/<routeBasePath>/1.0.0`.
242
+ * Can be configured through `versions.path`.
243
+ */
244
+ path: string;
245
+ /** Tags base path in the form of `<versionPath>/tags`. */
246
+ tagsPath: string;
247
+ /**
248
+ * The base URL to which the doc file path will be appended. Will be
249
+ * `undefined` if `editUrl` is `undefined` or a function.
250
+ */
251
+ editUrl?: string | undefined;
252
+ /**
253
+ * The base URL to which the localized doc file path will be appended. Will
254
+ * be `undefined` if `editUrl` is `undefined` or a function.
255
+ */
256
+ editUrlLocalized?: string | undefined;
257
+ /**
258
+ * "unmaintained" is the version before latest; "unreleased" is the version
259
+ * after latest. `null` is the latest version without a banner. Can be
260
+ * configured with `versions.banner`: `banner: "none"` will be transformed
261
+ * to `null` here.
262
+ */
263
+ banner: VersionBanner | null;
264
+ /** Show a badge with the version label at the top of each doc. */
265
+ badge: boolean;
266
+ /** Add a custom class name to the <html> element of each doc. */
267
+ className: string;
268
+ /**
269
+ * Whether this version is the "last" version. Can be configured with
270
+ * `lastVersion` option.
271
+ */
18
272
  isLast: boolean;
19
- docsSidebars: PropSidebars;
273
+ /**
274
+ * Like `versioned_sidebars/1.0.0.json`. Versioned sidebars file may be
275
+ * nonexistent since we don't create empty files.
276
+ */
277
+ sidebarFilePath: string | false | undefined;
278
+ /**
279
+ * Will be -1 for the latest docs, and `undefined` for everything else.
280
+ * Because `/docs/foo` should always be after `/docs/<versionName>/foo`.
281
+ */
282
+ routePriority: number | undefined;
20
283
  };
21
284
 
22
- type PropsSidebarItemBase = {
23
- customProps?: Record<string, unknown>;
285
+ export type DocFrontMatter = {
286
+ /**
287
+ * The last part of the doc ID (will be refactored in the future to be the
288
+ * full ID instead)
289
+ * @see {@link DocMetadata.id}
290
+ */
291
+ id?: string;
292
+ /**
293
+ * Will override the default title collected from h1 heading.
294
+ * @see {@link DocMetadata.title}
295
+ */
296
+ title?: string;
297
+ /**
298
+ * Front matter tags, unnormalized.
299
+ * @see {@link DocMetadata.tags}
300
+ */
301
+ tags?: FrontMatterTag[];
302
+ /**
303
+ * If there isn't a Markdown h1 heading (which, if there is, we don't
304
+ * remove), this front matter will cause the front matter title to not be
305
+ * displayed in the doc page.
306
+ */
307
+ hide_title?: boolean;
308
+ /** Hide the TOC on the right. */
309
+ hide_table_of_contents?: boolean;
310
+ /** Used in the head meta. */
311
+ keywords?: string[];
312
+ /** Used in the head meta. Should use `assets.image` in priority. */
313
+ image?: string;
314
+ /**
315
+ * Will override the default excerpt.
316
+ * @see {@link DocMetadata.description}
317
+ */
318
+ description?: string;
319
+ /**
320
+ * Custom slug appended after /<baseUrl>/<routeBasePath>/<versionPath>
321
+ * @see {@link DocMetadata.slug}
322
+ */
323
+ slug?: string;
324
+ /** Customizes the sidebar label for this doc. Will default to its title. */
325
+ sidebar_label?: string;
326
+ /**
327
+ * Controls the position of a doc inside the generated sidebar slice when
328
+ * using autogenerated sidebar items.
329
+ *
330
+ * @see https://docusaurus.io/docs/sidebar#autogenerated-sidebar-metadata
331
+ */
332
+ sidebar_position?: number;
333
+ /**
334
+ * Gives the corresponding sidebar label a special class name when using
335
+ * autogenerated sidebars.
336
+ */
337
+ sidebar_class_name?: string;
338
+ /**
339
+ * Will be propagated to the final sidebars data structure. Useful if you
340
+ * have swizzled sidebar-related code or simply querying doc data through
341
+ * sidebars.
342
+ */
343
+ sidebar_custom_props?: {[key: string]: unknown};
344
+ /**
345
+ * Changes the sidebar association of the current doc. Use `null` to make
346
+ * the current doc not associated to any sidebar.
347
+ */
348
+ displayed_sidebar?: string | null;
349
+ /**
350
+ * Customizes the pagination label for this doc. Will default to the sidebar
351
+ * label.
352
+ */
353
+ pagination_label?: string;
354
+ /** Overrides the default URL computed for this doc. */
355
+ custom_edit_url?: string | null;
356
+ /**
357
+ * Whether number prefix parsing is disabled on this doc.
358
+ * @see https://docusaurus.io/docs/sidebar#using-number-prefixes
359
+ */
360
+ parse_number_prefixes?: boolean;
361
+ /**
362
+ * Minimum TOC heading level. Must be between 2 and 6 and lower or equal to
363
+ * the max value.
364
+ */
365
+ toc_min_heading_level?: number;
366
+ /** Maximum TOC heading level. Must be between 2 and 6. */
367
+ toc_max_heading_level?: number;
368
+ /**
369
+ * The ID of the documentation you want the "Next" pagination to link to.
370
+ * Use `null` to disable showing "Next" for this page.
371
+ * @see {@link DocMetadata.next}
372
+ */
373
+ pagination_next?: string | null;
374
+ /**
375
+ * The ID of the documentation you want the "Previous" pagination to link
376
+ * to. Use `null` to disable showing "Previous" for this page.
377
+ * @see {@link DocMetadata.prev}
378
+ */
379
+ pagination_prev?: string | null;
380
+ /** Should this doc be excluded from production builds? */
381
+ draft?: boolean;
382
+ /** Allows overriding the last updated author and/or date. */
383
+ last_update?: FileChange;
24
384
  };
25
385
 
26
- export type PropSidebarItemLink = PropsSidebarItemBase & {
27
- type: 'link';
28
- href: string;
29
- label: string;
386
+ export type LastUpdateData = {
387
+ /** A timestamp in **seconds**, directly acquired from `git log`. */
388
+ lastUpdatedAt?: number;
389
+ /** `lastUpdatedAt` formatted as a date according to the current locale. */
390
+ formattedLastUpdatedAt?: string;
391
+ /** The author's name directly acquired from `git log`. */
392
+ lastUpdatedBy?: string;
30
393
  };
31
394
 
32
- export type PropSidebarItemCategory = PropsSidebarItemBase & {
33
- type: 'category';
34
- label: string;
35
- items: PropSidebarItem[];
36
- collapsed: boolean;
37
- collapsible: boolean;
395
+ export type DocMetadataBase = LastUpdateData & {
396
+ // TODO
397
+ /**
398
+ * Legacy versioned ID. Will be refactored in the future to be unversioned.
399
+ */
400
+ id: string;
401
+ // TODO
402
+ /**
403
+ * Unversioned ID. Should be preferred everywhere over `id` until the latter
404
+ * is refactored.
405
+ */
406
+ unversionedId: string;
407
+ /** The name of the version this doc belongs to. */
408
+ version: string;
409
+ /**
410
+ * Used to generate the page h1 heading, tab title, and pagination title.
411
+ */
412
+ title: string;
413
+ /**
414
+ * Description used in the meta. Could be an empty string (empty content)
415
+ */
416
+ description: string;
417
+ /** Path to the Markdown source, with `@site` alias. */
418
+ source: string;
419
+ /**
420
+ * Posix path relative to the content path. Can be `"."`.
421
+ * e.g. "folder/subfolder/subsubfolder"
422
+ */
423
+ sourceDirName: string;
424
+ /** `permalink` without base URL or version path. */
425
+ slug: string;
426
+ /** Full URL to this doc, with base URL and version path. */
427
+ permalink: string;
428
+ /**
429
+ * Draft docs will be excluded for production environment.
430
+ */
431
+ draft: boolean;
432
+ /**
433
+ * Position in an autogenerated sidebar slice, acquired through front matter
434
+ * or number prefix.
435
+ */
436
+ sidebarPosition?: number;
437
+ /**
438
+ * Acquired from the options; can be customized with front matter.
439
+ * `custom_edit_url` will always lead to it being null, but you should treat
440
+ * `undefined` and `null` as equivalent.
441
+ */
442
+ editUrl?: string | null;
443
+ /** Tags, normalized. */
444
+ tags: Tag[];
445
+ /** Front matter, as-is. */
446
+ frontMatter: DocFrontMatter & {[key: string]: unknown};
447
+ };
448
+
449
+ export type DocMetadata = DocMetadataBase &
450
+ PropNavigation & {
451
+ /** Name of the sidebar this doc is associated with. */
452
+ sidebar?: string;
453
+ };
454
+
455
+ export type CategoryGeneratedIndexMetadata = Required<
456
+ Omit<
457
+ import('./sidebars/types').SidebarItemCategoryLinkGeneratedIndex,
458
+ 'type'
459
+ >,
460
+ 'title'
461
+ > & {
462
+ navigation: PropNavigation;
463
+ /**
464
+ * Name of the sidebar this doc is associated with. Unlike
465
+ * `DocMetadata.sidebar`, this will always be defined, because a generated
466
+ * index can only be generated from a category.
467
+ */
468
+ sidebar: string;
469
+ };
470
+
471
+ export type PropNavigationLink = {
472
+ readonly title: string;
473
+ readonly permalink: string;
474
+ };
475
+ export type PropNavigation = {
476
+ /**
477
+ * Used in pagination. Content is just a subset of another doc's metadata.
478
+ */
479
+ readonly previous?: PropNavigationLink;
480
+ /**
481
+ * Used in pagination. Content is just a subset of another doc's metadata.
482
+ */
483
+ readonly next?: PropNavigationLink;
38
484
  };
39
485
 
40
- export type PropSidebarItem = PropSidebarItemLink | PropSidebarItemCategory;
486
+ export type PropVersionDoc = Pick<
487
+ DocMetadata,
488
+ 'id' | 'title' | 'description' | 'sidebar'
489
+ >;
41
490
 
42
- export type PropSidebars = {
43
- [sidebarId: string]: PropSidebarItem[];
491
+ export type PropVersionDocs = {
492
+ [docId: string]: PropVersionDoc;
44
493
  };
45
494
 
46
- export type {
47
- GlobalVersion as GlobalDataVersion,
48
- GlobalDoc as GlobalDataDoc,
49
- } from './types';
495
+ export type PropDocContent = LoadedMDXContent<
496
+ DocFrontMatter,
497
+ DocMetadata,
498
+ Assets
499
+ >;
500
+
501
+ export type PropVersionMetadata = Pick<
502
+ VersionMetadata,
503
+ 'label' | 'banner' | 'badge' | 'className' | 'isLast'
504
+ > & {
505
+ /** ID of the docs plugin this version belongs to. */
506
+ pluginId: string;
507
+ /** Name of this version. */
508
+ version: string;
509
+ /** Sidebars contained in this version. */
510
+ docsSidebars: PropSidebars;
511
+ /** Docs contained in this version. */
512
+ docs: PropVersionDocs;
513
+ };
514
+
515
+ export type PropCategoryGeneratedIndex = Omit<
516
+ CategoryGeneratedIndexMetadata,
517
+ 'sidebar'
518
+ >;
519
+
520
+ export type PropSidebarItemLink =
521
+ import('./sidebars/types').PropSidebarItemLink;
522
+ export type PropSidebarItemHtml =
523
+ import('./sidebars/types').PropSidebarItemHtml;
524
+ export type PropSidebarItemCategory =
525
+ import('./sidebars/types').PropSidebarItemCategory;
526
+ export type PropSidebarItem = import('./sidebars/types').PropSidebarItem;
527
+ export type PropSidebarBreadcrumbsItem =
528
+ import('./sidebars/types').PropSidebarBreadcrumbsItem;
529
+ export type PropSidebar = import('./sidebars/types').PropSidebar;
530
+ export type PropSidebars = import('./sidebars/types').PropSidebars;
531
+
532
+ export type PropTagDocListDoc = Pick<
533
+ DocMetadata,
534
+ 'id' | 'title' | 'description' | 'permalink'
535
+ >;
536
+ export type PropTagDocList = TagModule & {items: PropTagDocListDoc[]};
537
+
538
+ export type PropTagsListPage = {
539
+ tags: TagsListItem[];
540
+ };
541
+
542
+ export type LoadedVersion = VersionMetadata & {
543
+ docs: DocMetadata[];
544
+ drafts: DocMetadata[];
545
+ sidebars: import('./sidebars/types').Sidebars;
546
+ };
547
+
548
+ export type LoadedContent = {
549
+ loadedVersions: LoadedVersion[];
550
+ };
551
+
552
+ export default function pluginContentDocs(
553
+ context: LoadContext,
554
+ options: PluginOptions,
555
+ ): Promise<Plugin<LoadedContent>>;
50
556
  }
51
557
 
52
558
  declare module '@theme/DocItem' {
53
- import type {TOCItem} from '@docusaurus/types';
559
+ import type {PropDocContent} from '@docusaurus/plugin-content-docs';
54
560
 
55
561
  export type DocumentRoute = {
56
562
  readonly component: () => JSX.Element;
@@ -59,81 +565,54 @@ declare module '@theme/DocItem' {
59
565
  readonly sidebar?: string;
60
566
  };
61
567
 
62
- export type FrontMatter = {
63
- readonly id: string;
64
- readonly title: string;
65
- readonly image?: string;
66
- readonly keywords?: readonly string[];
67
- readonly hide_title?: boolean;
68
- readonly hide_table_of_contents?: boolean;
69
- };
70
-
71
- export type Metadata = {
72
- readonly description?: string;
73
- readonly title?: string;
74
- readonly permalink?: string;
75
- readonly editUrl?: string;
76
- readonly lastUpdatedAt?: number;
77
- readonly formattedLastUpdatedAt?: string;
78
- readonly lastUpdatedBy?: string;
79
- readonly version?: string;
80
- readonly previous?: {readonly permalink: string; readonly title: string};
81
- readonly next?: {readonly permalink: string; readonly title: string};
82
- };
83
-
84
- export type Props = {
568
+ export interface Props {
85
569
  readonly route: DocumentRoute;
86
- readonly versionMetadata: PropVersionMetadata;
87
- readonly content: {
88
- readonly frontMatter: FrontMatter;
89
- readonly metadata: Metadata;
90
- readonly toc: readonly TOCItem[];
91
- readonly contentTitle: string | undefined;
92
- (): JSX.Element;
93
- };
94
- };
570
+ readonly content: PropDocContent;
571
+ }
95
572
 
96
- const DocItem: (props: Props) => JSX.Element;
97
- export default DocItem;
573
+ export default function DocItem(props: Props): JSX.Element;
98
574
  }
99
575
 
100
- declare module '@theme/DocVersionBanner' {
101
- import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs-types';
576
+ declare module '@theme/DocCategoryGeneratedIndexPage' {
577
+ import type {PropCategoryGeneratedIndex} from '@docusaurus/plugin-content-docs';
102
578
 
103
- export type Props = {
104
- readonly versionMetadata: PropVersionMetadata;
105
- };
579
+ export interface Props {
580
+ readonly categoryGeneratedIndex: PropCategoryGeneratedIndex;
581
+ }
106
582
 
107
- const DocVersionBanner: (props: Props) => JSX.Element;
108
- export default DocVersionBanner;
583
+ export default function DocCategoryGeneratedIndexPage(
584
+ props: Props,
585
+ ): JSX.Element;
109
586
  }
110
587
 
111
- declare module '@theme/DocPage' {
112
- import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs-types';
113
- import type {DocumentRoute} from '@theme/DocItem';
588
+ declare module '@theme/DocTagsListPage' {
589
+ import type {PropTagsListPage} from '@docusaurus/plugin-content-docs';
114
590
 
115
- export type Props = {
116
- readonly location: {readonly pathname: string};
117
- readonly versionMetadata: PropVersionMetadata;
118
- readonly route: {
119
- readonly path: string;
120
- readonly component: () => JSX.Element;
121
- readonly routes: DocumentRoute[];
122
- };
123
- };
591
+ export interface Props extends PropTagsListPage {}
592
+ export default function DocTagsListPage(props: Props): JSX.Element;
593
+ }
594
+
595
+ declare module '@theme/DocTagDocListPage' {
596
+ import type {PropTagDocList} from '@docusaurus/plugin-content-docs';
124
597
 
125
- const DocPage: (props: Props) => JSX.Element;
126
- export default DocPage;
598
+ export interface Props {
599
+ readonly tag: PropTagDocList;
600
+ }
601
+ export default function DocTagDocListPage(props: Props): JSX.Element;
127
602
  }
128
603
 
129
- declare module '@theme/Seo' {
130
- export type Props = {
131
- readonly title?: string;
132
- readonly description?: string;
133
- readonly keywords?: readonly string[] | string;
134
- readonly image?: string;
135
- };
604
+ declare module '@theme/DocBreadcrumbs' {
605
+ export default function DocBreadcrumbs(): JSX.Element;
606
+ }
607
+
608
+ declare module '@theme/DocPage' {
609
+ import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs';
610
+ import type {RouteConfigComponentProps} from 'react-router-config';
611
+ import type {Required} from 'utility-types';
612
+
613
+ export interface Props extends Required<RouteConfigComponentProps, 'route'> {
614
+ readonly versionMetadata: PropVersionMetadata;
615
+ }
136
616
 
137
- const Seo: (props: Props) => JSX.Element;
138
- export default Seo;
617
+ export default function DocPage(props: Props): JSX.Element;
139
618
  }