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

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 (214) hide show
  1. package/lib/categoryGeneratedIndex.d.ts +12 -0
  2. package/lib/categoryGeneratedIndex.js +35 -0
  3. package/lib/cli.d.ts +2 -2
  4. package/lib/cli.js +37 -51
  5. package/lib/client/docsClientUtils.d.ts +6 -26
  6. package/lib/client/docsClientUtils.js +28 -34
  7. package/lib/{theme/hooks/useDocs.d.ts → client/index.d.ts} +4 -3
  8. package/lib/{theme/hooks/useDocs.js → client/index.js} +28 -25
  9. package/lib/docs.d.ts +31 -4
  10. package/lib/docs.js +160 -54
  11. package/{src/__tests__/__fixtures__/simple-site/docusaurus.config.js → lib/frontMatter.d.ts} +4 -8
  12. package/lib/{docFrontMatter.js → frontMatter.js} +13 -6
  13. package/lib/globalData.d.ts +2 -2
  14. package/lib/globalData.js +32 -3
  15. package/lib/index.d.ts +4 -3
  16. package/lib/index.js +123 -136
  17. package/lib/lastUpdate.d.ts +4 -6
  18. package/lib/lastUpdate.js +22 -26
  19. package/lib/markdown/index.d.ts +3 -6
  20. package/lib/markdown/index.js +3 -3
  21. package/lib/markdown/linkify.d.ts +1 -1
  22. package/lib/markdown/linkify.js +7 -3
  23. package/lib/numberPrefix.d.ts +1 -1
  24. package/lib/numberPrefix.js +16 -21
  25. package/lib/options.d.ts +3 -5
  26. package/lib/options.js +55 -19
  27. package/lib/props.d.ts +7 -2
  28. package/lib/props.js +70 -14
  29. package/lib/routes.d.ts +28 -0
  30. package/lib/routes.js +110 -0
  31. package/lib/server-export.d.ts +8 -0
  32. package/lib/server-export.js +23 -0
  33. package/lib/{sidebarItemsGenerator.d.ts → sidebars/generator.d.ts} +1 -6
  34. package/lib/sidebars/generator.js +209 -0
  35. package/lib/sidebars/index.d.ts +13 -0
  36. package/lib/sidebars/index.js +94 -0
  37. package/lib/sidebars/normalization.d.ts +13 -0
  38. package/lib/sidebars/normalization.js +55 -0
  39. package/lib/sidebars/postProcessor.d.ts +8 -0
  40. package/lib/sidebars/postProcessor.js +65 -0
  41. package/lib/sidebars/processor.d.ts +10 -0
  42. package/lib/sidebars/processor.js +79 -0
  43. package/lib/sidebars/types.d.ts +174 -0
  44. package/{src/__tests__/__fixtures__/site-with-autogenerated-sidebar/partialAutogeneratedSidebars2.js → lib/sidebars/types.js} +2 -10
  45. package/lib/sidebars/utils.d.ts +54 -0
  46. package/lib/sidebars/utils.js +255 -0
  47. package/lib/sidebars/validation.d.ts +11 -0
  48. package/lib/sidebars/validation.js +138 -0
  49. package/lib/slug.d.ts +6 -4
  50. package/lib/slug.js +29 -19
  51. package/{src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docusaurus.config.js → lib/tags.d.ts} +2 -8
  52. package/lib/tags.js +21 -0
  53. package/lib/translations.d.ts +2 -2
  54. package/lib/translations.js +89 -49
  55. package/lib/types.d.ts +60 -130
  56. package/lib/versions.d.ts +29 -4
  57. package/lib/versions.js +134 -97
  58. package/package.json +30 -26
  59. package/src/categoryGeneratedIndex.ts +55 -0
  60. package/src/cli.ts +47 -63
  61. package/src/client/docsClientUtils.ts +38 -73
  62. package/src/{theme/hooks/useDocs.ts → client/index.ts} +16 -11
  63. package/{types.d.ts → src/deps.d.ts} +1 -1
  64. package/src/docs.ts +212 -46
  65. package/src/{docFrontMatter.ts → frontMatter.ts} +21 -26
  66. package/src/globalData.ts +53 -3
  67. package/src/index.ts +168 -178
  68. package/src/lastUpdate.ts +26 -33
  69. package/src/markdown/index.ts +10 -16
  70. package/src/markdown/linkify.ts +6 -2
  71. package/src/numberPrefix.ts +19 -26
  72. package/src/options.ts +60 -32
  73. package/src/plugin-content-docs.d.ts +263 -40
  74. package/src/props.ts +105 -21
  75. package/src/routes.ts +185 -0
  76. package/src/server-export.ts +24 -0
  77. package/src/sidebars/README.md +9 -0
  78. package/src/sidebars/generator.ts +292 -0
  79. package/src/sidebars/index.ts +120 -0
  80. package/src/sidebars/normalization.ts +85 -0
  81. package/src/sidebars/postProcessor.ts +89 -0
  82. package/src/sidebars/processor.ts +120 -0
  83. package/src/sidebars/types.ts +274 -0
  84. package/src/sidebars/utils.ts +388 -0
  85. package/src/sidebars/validation.ts +174 -0
  86. package/src/slug.ts +40 -23
  87. package/src/tags.ts +19 -0
  88. package/src/translations.ts +124 -66
  89. package/src/types.ts +67 -187
  90. package/src/versions.ts +205 -110
  91. package/lib/.tsbuildinfo +0 -4717
  92. package/lib/docFrontMatter.d.ts +0 -21
  93. package/lib/sidebarItemsGenerator.js +0 -211
  94. package/lib/sidebars.d.ts +0 -42
  95. package/lib/sidebars.js +0 -309
  96. package/src/__tests__/__fixtures__/bad-id-site/docs/invalid-id.md +0 -5
  97. package/src/__tests__/__fixtures__/bad-slug-on-doc-home-site/docs/docWithSlug.md +0 -5
  98. package/src/__tests__/__fixtures__/empty-site/docusaurus.config.js +0 -16
  99. package/src/__tests__/__fixtures__/empty-site/sidebars.json +0 -1
  100. package/src/__tests__/__fixtures__/sidebars/sidebars-category-shorthand.js +0 -34
  101. package/src/__tests__/__fixtures__/sidebars/sidebars-category-wrong-items.json +0 -11
  102. package/src/__tests__/__fixtures__/sidebars/sidebars-category-wrong-label.json +0 -11
  103. package/src/__tests__/__fixtures__/sidebars/sidebars-category.js +0 -44
  104. package/src/__tests__/__fixtures__/sidebars/sidebars-collapsed-first-level.json +0 -20
  105. package/src/__tests__/__fixtures__/sidebars/sidebars-collapsed.json +0 -21
  106. package/src/__tests__/__fixtures__/sidebars/sidebars-doc-id-not-string.json +0 -10
  107. package/src/__tests__/__fixtures__/sidebars/sidebars-first-level-not-category.js +0 -20
  108. package/src/__tests__/__fixtures__/sidebars/sidebars-link-wrong-href.json +0 -11
  109. package/src/__tests__/__fixtures__/sidebars/sidebars-link-wrong-label.json +0 -11
  110. package/src/__tests__/__fixtures__/sidebars/sidebars-link.json +0 -11
  111. package/src/__tests__/__fixtures__/sidebars/sidebars-unknown-type.json +0 -14
  112. package/src/__tests__/__fixtures__/sidebars/sidebars-wrong-field.json +0 -20
  113. package/src/__tests__/__fixtures__/sidebars/sidebars.json +0 -20
  114. package/src/__tests__/__fixtures__/simple-site/docs/foo/bar.md +0 -69
  115. package/src/__tests__/__fixtures__/simple-site/docs/foo/baz.md +0 -67
  116. package/src/__tests__/__fixtures__/simple-site/docs/headingAsTitle.md +0 -1
  117. package/src/__tests__/__fixtures__/simple-site/docs/hello.md +0 -52
  118. package/src/__tests__/__fixtures__/simple-site/docs/ipsum.md +0 -5
  119. package/src/__tests__/__fixtures__/simple-site/docs/lorem.md +0 -6
  120. package/src/__tests__/__fixtures__/simple-site/docs/rootAbsoluteSlug.md +0 -5
  121. package/src/__tests__/__fixtures__/simple-site/docs/rootRelativeSlug.md +0 -5
  122. package/src/__tests__/__fixtures__/simple-site/docs/rootResolvedSlug.md +0 -5
  123. package/src/__tests__/__fixtures__/simple-site/docs/rootTryToEscapeSlug.md +0 -5
  124. package/src/__tests__/__fixtures__/simple-site/docs/slugs/absoluteSlug.md +0 -5
  125. package/src/__tests__/__fixtures__/simple-site/docs/slugs/relativeSlug.md +0 -5
  126. package/src/__tests__/__fixtures__/simple-site/docs/slugs/resolvedSlug.md +0 -5
  127. package/src/__tests__/__fixtures__/simple-site/docs/slugs/tryToEscapeSlug.md +0 -5
  128. package/src/__tests__/__fixtures__/simple-site/sidebars.json +0 -23
  129. package/src/__tests__/__fixtures__/simple-site/wrong-sidebars.json +0 -7
  130. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/0-getting-started.md +0 -3
  131. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/1-installation.md +0 -3
  132. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/00_api-overview.md +0 -3
  133. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/01_Core APIs/0 --- Client API.md +0 -1
  134. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/01_Core APIs/1 --- Server API.md +0 -1
  135. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/02_Extension APIs/0. Plugin API.md +0 -1
  136. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/02_Extension APIs/1. Theme API.md +0 -1
  137. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/02_Extension APIs/_category_.yml +0 -1
  138. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/03_api-end.md +0 -3
  139. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/_category_.json +0 -3
  140. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/0-guide2.5.md +0 -8
  141. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/02-guide2.md +0 -7
  142. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/_category_.json +0 -3
  143. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/a-guide4.md +0 -7
  144. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/b-guide5.md +0 -7
  145. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/guide3.md +0 -8
  146. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/z-guide1.md +0 -8
  147. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/partialAutogeneratedSidebars.js +0 -23
  148. package/src/__tests__/__fixtures__/site-with-doc-label/docs/hello-1.md +0 -7
  149. package/src/__tests__/__fixtures__/site-with-doc-label/docs/hello-2.md +0 -8
  150. package/src/__tests__/__fixtures__/site-with-doc-label/docusaurus.config.js +0 -14
  151. package/src/__tests__/__fixtures__/site-with-doc-label/sidebars.json +0 -14
  152. package/src/__tests__/__fixtures__/versioned-site/community/team.md +0 -1
  153. package/src/__tests__/__fixtures__/versioned-site/community_sidebars.json +0 -3
  154. package/src/__tests__/__fixtures__/versioned-site/community_versioned_docs/version-1.0.0/team.md +0 -1
  155. package/src/__tests__/__fixtures__/versioned-site/community_versioned_sidebars/version-1.0.0-sidebars.json +0 -3
  156. package/src/__tests__/__fixtures__/versioned-site/community_versions.json +0 -1
  157. package/src/__tests__/__fixtures__/versioned-site/docs/foo/bar.md +0 -4
  158. package/src/__tests__/__fixtures__/versioned-site/docs/hello.md +0 -1
  159. package/src/__tests__/__fixtures__/versioned-site/docs/slugs/absoluteSlug.md +0 -5
  160. package/src/__tests__/__fixtures__/versioned-site/docs/slugs/relativeSlug.md +0 -5
  161. package/src/__tests__/__fixtures__/versioned-site/docs/slugs/resolvedSlug.md +0 -5
  162. package/src/__tests__/__fixtures__/versioned-site/docs/slugs/tryToEscapeSlug.md +0 -5
  163. package/src/__tests__/__fixtures__/versioned-site/docusaurus.config.js +0 -18
  164. package/src/__tests__/__fixtures__/versioned-site/i18n/en/docusaurus-plugin-content-docs/version-1.0.0/hello.md +0 -1
  165. package/src/__tests__/__fixtures__/versioned-site/i18n/en/docusaurus-plugin-content-docs-community/current/team.md +0 -5
  166. package/src/__tests__/__fixtures__/versioned-site/i18n/fr/docusaurus-plugin-content-docs/version-1.0.0/hello.md +0 -1
  167. package/src/__tests__/__fixtures__/versioned-site/sidebars.json +0 -10
  168. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.0/foo/bar.md +0 -4
  169. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.0/foo/baz.md +0 -1
  170. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.0/hello.md +0 -1
  171. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/foo/bar.md +0 -1
  172. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/hello.md +0 -1
  173. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootAbsoluteSlug.md +0 -5
  174. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootRelativeSlug.md +0 -5
  175. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootResolvedSlug.md +0 -5
  176. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootTryToEscapeSlug.md +0 -5
  177. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/absoluteSlug.md +0 -5
  178. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/relativeSlug.md +0 -5
  179. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/resolvedSlug.md +0 -5
  180. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/tryToEscapeSlug.md +0 -5
  181. package/src/__tests__/__fixtures__/versioned-site/versioned_sidebars/version-1.0.0-sidebars.json +0 -11
  182. package/src/__tests__/__fixtures__/versioned-site/versioned_sidebars/version-1.0.1-sidebars.json +0 -10
  183. package/src/__tests__/__fixtures__/versioned-site/versioned_sidebars/version-withSlugs-sidebars.json +0 -5
  184. package/src/__tests__/__fixtures__/versioned-site/versions.json +0 -5
  185. package/src/__tests__/__snapshots__/cli.test.ts.snap +0 -90
  186. package/src/__tests__/__snapshots__/index.test.ts.snap +0 -1907
  187. package/src/__tests__/__snapshots__/sidebars.test.ts.snap +0 -218
  188. package/src/__tests__/__snapshots__/translations.test.ts.snap +0 -487
  189. package/src/__tests__/cli.test.ts +0 -333
  190. package/src/__tests__/docFrontMatter.test.ts +0 -204
  191. package/src/__tests__/docs.test.ts +0 -875
  192. package/src/__tests__/index.test.ts +0 -1831
  193. package/src/__tests__/lastUpdate.test.ts +0 -68
  194. package/src/__tests__/numberPrefix.test.ts +0 -199
  195. package/src/__tests__/options.test.ts +0 -232
  196. package/src/__tests__/sidebarItemsGenerator.test.ts +0 -336
  197. package/src/__tests__/sidebars.test.ts +0 -638
  198. package/src/__tests__/slug.test.ts +0 -109
  199. package/src/__tests__/translations.test.ts +0 -159
  200. package/src/__tests__/versions.test.ts +0 -718
  201. package/src/client/__tests__/docsClientUtils.test.ts +0 -372
  202. package/src/markdown/__tests__/__fixtures__/docs/doc-localized.md +0 -1
  203. package/src/markdown/__tests__/__fixtures__/docs/doc1.md +0 -13
  204. package/src/markdown/__tests__/__fixtures__/docs/doc2.md +0 -12
  205. package/src/markdown/__tests__/__fixtures__/docs/doc4.md +0 -19
  206. package/src/markdown/__tests__/__fixtures__/docs/doc5.md +0 -6
  207. package/src/markdown/__tests__/__fixtures__/docs/subdir/doc3.md +0 -3
  208. package/src/markdown/__tests__/__fixtures__/versioned_docs/version-1.0.0/doc2.md +0 -7
  209. package/src/markdown/__tests__/__fixtures__/versioned_docs/version-1.0.0/subdir/doc1.md +0 -3
  210. package/src/markdown/__tests__/__snapshots__/linkify.test.ts.snap +0 -82
  211. package/src/markdown/__tests__/linkify.test.ts +0 -190
  212. package/src/sidebarItemsGenerator.ts +0 -307
  213. package/src/sidebars.ts +0 -489
  214. package/tsconfig.json +0 -9
@@ -0,0 +1,174 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import type { Optional, Required } from 'utility-types';
8
+ import type { DocMetadataBase, VersionMetadata } from '../types';
9
+ import type { NumberPrefixParser, SidebarOptions, CategoryIndexMatcher } from '@docusaurus/plugin-content-docs';
10
+ import type { Slugger } from '@docusaurus/utils';
11
+ declare type Expand<T extends {
12
+ [x: string]: unknown;
13
+ }> = {
14
+ [P in keyof T]: T[P];
15
+ };
16
+ export declare type SidebarItemBase = {
17
+ className?: string;
18
+ customProps?: {
19
+ [key: string]: unknown;
20
+ };
21
+ };
22
+ export declare type SidebarItemDoc = SidebarItemBase & {
23
+ type: 'doc' | 'ref';
24
+ label?: string;
25
+ id: string;
26
+ };
27
+ export declare type SidebarItemHtml = SidebarItemBase & {
28
+ type: 'html';
29
+ value: string;
30
+ defaultStyle?: boolean;
31
+ };
32
+ export declare type SidebarItemLink = SidebarItemBase & {
33
+ type: 'link';
34
+ href: string;
35
+ label: string;
36
+ };
37
+ export declare type SidebarItemAutogenerated = SidebarItemBase & {
38
+ type: 'autogenerated';
39
+ dirName: string;
40
+ };
41
+ declare type SidebarItemCategoryBase = SidebarItemBase & {
42
+ type: 'category';
43
+ label: string;
44
+ collapsed: boolean;
45
+ collapsible: boolean;
46
+ };
47
+ export declare type SidebarItemCategoryLinkDoc = {
48
+ type: 'doc';
49
+ id: string;
50
+ };
51
+ export declare type SidebarItemCategoryLinkGeneratedIndexConfig = {
52
+ type: 'generated-index';
53
+ slug?: string;
54
+ title?: string;
55
+ description?: string;
56
+ image?: string;
57
+ keywords?: string | readonly string[];
58
+ };
59
+ export declare type SidebarItemCategoryLinkGeneratedIndex = {
60
+ type: 'generated-index';
61
+ slug: string;
62
+ permalink: string;
63
+ title?: string;
64
+ description?: string;
65
+ image?: string;
66
+ keywords?: string | readonly string[];
67
+ };
68
+ export declare type SidebarItemCategoryLinkConfig = SidebarItemCategoryLinkDoc | SidebarItemCategoryLinkGeneratedIndexConfig;
69
+ export declare type SidebarItemCategoryLink = SidebarItemCategoryLinkDoc | SidebarItemCategoryLinkGeneratedIndex;
70
+ export declare type SidebarItemCategoryConfig = Expand<Optional<SidebarItemCategoryBase, 'collapsed' | 'collapsible'> & {
71
+ items: SidebarCategoriesShorthand | SidebarItemConfig[];
72
+ link?: SidebarItemCategoryLinkConfig;
73
+ }>;
74
+ export declare type SidebarCategoriesShorthand = {
75
+ [sidebarCategory: string]: SidebarCategoriesShorthand | SidebarItemConfig[];
76
+ };
77
+ export declare type SidebarItemConfig = SidebarItemDoc | SidebarItemHtml | SidebarItemLink | SidebarItemAutogenerated | SidebarItemCategoryConfig | string | SidebarCategoriesShorthand;
78
+ export declare type SidebarConfig = SidebarCategoriesShorthand | SidebarItemConfig[];
79
+ export declare type SidebarsConfig = {
80
+ [sidebarId: string]: SidebarConfig;
81
+ };
82
+ export declare type NormalizedSidebarItemCategory = Expand<Optional<SidebarItemCategoryBase, 'collapsed' | 'collapsible'> & {
83
+ items: NormalizedSidebarItem[];
84
+ link?: SidebarItemCategoryLinkConfig;
85
+ }>;
86
+ export declare type NormalizedSidebarItem = SidebarItemDoc | SidebarItemHtml | SidebarItemLink | NormalizedSidebarItemCategory | SidebarItemAutogenerated;
87
+ export declare type NormalizedSidebar = NormalizedSidebarItem[];
88
+ export declare type NormalizedSidebars = {
89
+ [sidebarId: string]: NormalizedSidebar;
90
+ };
91
+ export declare type ProcessedSidebarItemCategory = Expand<Optional<SidebarItemCategoryBase, 'collapsed' | 'collapsible'> & {
92
+ items: ProcessedSidebarItem[];
93
+ link?: SidebarItemCategoryLinkConfig;
94
+ }>;
95
+ export declare type ProcessedSidebarItem = SidebarItemDoc | SidebarItemHtml | SidebarItemLink | ProcessedSidebarItemCategory;
96
+ export declare type ProcessedSidebar = ProcessedSidebarItem[];
97
+ export declare type ProcessedSidebars = {
98
+ [sidebarId: string]: ProcessedSidebar;
99
+ };
100
+ export declare type SidebarItemCategory = Expand<SidebarItemCategoryBase & {
101
+ items: SidebarItem[];
102
+ link?: SidebarItemCategoryLink;
103
+ }>;
104
+ export declare type SidebarItemCategoryWithLink = Required<SidebarItemCategory, 'link'>;
105
+ export declare type SidebarItemCategoryWithGeneratedIndex = SidebarItemCategoryWithLink & {
106
+ link: SidebarItemCategoryLinkGeneratedIndex;
107
+ };
108
+ export declare type SidebarItem = SidebarItemDoc | SidebarItemHtml | SidebarItemLink | SidebarItemCategory;
109
+ export declare type SidebarNavigationItem = SidebarItemDoc | SidebarItemCategoryWithLink;
110
+ export declare type Sidebar = SidebarItem[];
111
+ export declare type SidebarItemType = SidebarItem['type'];
112
+ export declare type Sidebars = {
113
+ [sidebarId: string]: Sidebar;
114
+ };
115
+ export declare type PropSidebarItemCategory = Expand<SidebarItemCategoryBase & {
116
+ items: PropSidebarItem[];
117
+ href?: string;
118
+ }>;
119
+ export declare type PropSidebarItemLink = SidebarItemLink & {
120
+ docId?: string;
121
+ };
122
+ export declare type PropSidebarItemHtml = SidebarItemHtml;
123
+ export declare type PropSidebarItem = PropSidebarItemLink | PropSidebarItemCategory | PropSidebarItemHtml;
124
+ export declare type PropSidebar = PropSidebarItem[];
125
+ export declare type PropSidebars = {
126
+ [sidebarId: string]: PropSidebar;
127
+ };
128
+ export declare type PropSidebarBreadcrumbsItem = PropSidebarItemLink | PropSidebarItemCategory;
129
+ export declare type PropVersionDoc = {
130
+ id: string;
131
+ title: string;
132
+ description?: string;
133
+ sidebar?: string;
134
+ };
135
+ export declare type PropVersionDocs = {
136
+ [docId: string]: PropVersionDoc;
137
+ };
138
+ export declare type CategoryMetadataFile = {
139
+ label?: string;
140
+ position?: number;
141
+ collapsed?: boolean;
142
+ collapsible?: boolean;
143
+ className?: string;
144
+ link?: SidebarItemCategoryLinkConfig | null;
145
+ customProps?: {
146
+ [key: string]: unknown;
147
+ };
148
+ };
149
+ export declare type SidebarItemsGeneratorDoc = Pick<DocMetadataBase, 'id' | 'unversionedId' | 'title' | 'frontMatter' | 'source' | 'sourceDirName' | 'sidebarPosition'>;
150
+ export declare type SidebarItemsGeneratorVersion = Pick<VersionMetadata, 'versionName' | 'contentPath'>;
151
+ export declare type SidebarItemsGeneratorArgs = {
152
+ item: SidebarItemAutogenerated;
153
+ version: SidebarItemsGeneratorVersion;
154
+ docs: SidebarItemsGeneratorDoc[];
155
+ numberPrefixParser: NumberPrefixParser;
156
+ isCategoryIndex: CategoryIndexMatcher;
157
+ categoriesMetadata: {
158
+ [filePath: string]: CategoryMetadataFile;
159
+ };
160
+ };
161
+ export declare type SidebarItemsGenerator = (generatorArgs: SidebarItemsGeneratorArgs) => Promise<NormalizedSidebar>;
162
+ export declare type SidebarItemsGeneratorOptionArgs = {
163
+ defaultSidebarItemsGenerator: SidebarItemsGenerator;
164
+ } & SidebarItemsGeneratorArgs;
165
+ export declare type SidebarItemsGeneratorOption = (generatorArgs: SidebarItemsGeneratorOptionArgs) => Promise<NormalizedSidebarItem[]>;
166
+ export declare type SidebarProcessorParams = {
167
+ sidebarItemsGenerator: SidebarItemsGeneratorOption;
168
+ numberPrefixParser: NumberPrefixParser;
169
+ docs: DocMetadataBase[];
170
+ version: VersionMetadata;
171
+ categoryLabelSlugger: Slugger;
172
+ sidebarOptions: SidebarOptions;
173
+ };
174
+ export {};
@@ -1,16 +1,8 @@
1
+ "use strict";
1
2
  /**
2
3
  * Copyright (c) Facebook, Inc. and its affiliates.
3
4
  *
4
5
  * This source code is licensed under the MIT license found in the
5
6
  * LICENSE file in the root directory of this source tree.
6
7
  */
7
-
8
- module.exports = {
9
- someSidebar: [
10
- {type: 'doc', id: 'API/api-end'},
11
- {
12
- type: 'autogenerated',
13
- dirName: '3-API',
14
- },
15
- ],
16
- };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import type { Sidebars, Sidebar, SidebarItem, SidebarItemCategory, SidebarItemLink, SidebarItemDoc, SidebarCategoriesShorthand, SidebarItemConfig, SidebarItemCategoryWithGeneratedIndex, SidebarNavigationItem } from './types';
8
+ import type { DocMetadataBase, DocNavLink } from '../types';
9
+ export declare function isCategoriesShorthand(item: SidebarItemConfig): item is SidebarCategoriesShorthand;
10
+ export declare function transformSidebarItems(sidebar: Sidebar, updateFn: (item: SidebarItem) => SidebarItem): Sidebar;
11
+ export declare function collectSidebarDocItems(sidebar: Sidebar): SidebarItemDoc[];
12
+ export declare function collectSidebarCategories(sidebar: Sidebar): SidebarItemCategory[];
13
+ export declare function collectSidebarLinks(sidebar: Sidebar): SidebarItemLink[];
14
+ export declare function collectSidebarDocIds(sidebar: Sidebar): string[];
15
+ export declare function collectSidebarNavigation(sidebar: Sidebar): SidebarNavigationItem[];
16
+ export declare function collectSidebarsDocIds(sidebars: Sidebars): {
17
+ [sidebarId: string]: string[];
18
+ };
19
+ export declare function collectSidebarsNavigations(sidebars: Sidebars): {
20
+ [sidebarId: string]: SidebarNavigationItem[];
21
+ };
22
+ export declare type SidebarNavigation = {
23
+ sidebarName: string | undefined;
24
+ previous: SidebarNavigationItem | undefined;
25
+ next: SidebarNavigationItem | undefined;
26
+ };
27
+ export declare type SidebarsUtils = {
28
+ sidebars: Sidebars;
29
+ getFirstDocIdOfFirstSidebar: () => string | undefined;
30
+ getSidebarNameByDocId: (docId: string) => string | undefined;
31
+ getDocNavigation: (unversionedId: string, versionedId: string, displayedSidebar: string | null | undefined) => SidebarNavigation;
32
+ getCategoryGeneratedIndexList: () => SidebarItemCategoryWithGeneratedIndex[];
33
+ getCategoryGeneratedIndexNavigation: (categoryGeneratedIndexPermalink: string) => SidebarNavigation;
34
+ /**
35
+ * This function may return undefined. This is usually a user mistake, because
36
+ * it means this sidebar will never be displayed; however, we can still use
37
+ * `displayed_sidebar` to make it displayed. Pretty weird but valid use-case
38
+ */
39
+ getFirstLink: (sidebarId: string) => {
40
+ type: 'doc';
41
+ id: string;
42
+ label: string;
43
+ } | {
44
+ type: 'generated-index';
45
+ permalink: string;
46
+ label: string;
47
+ } | undefined;
48
+ checkSidebarsDocIds: (validDocIds: string[], sidebarFilePath: string) => void;
49
+ };
50
+ export declare function createSidebarsUtils(sidebars: Sidebars): SidebarsUtils;
51
+ export declare function toDocNavigationLink(doc: DocMetadataBase): DocNavLink;
52
+ export declare function toNavigationLink(navigationItem: SidebarNavigationItem | undefined, docsById: {
53
+ [docId: string]: DocMetadataBase;
54
+ }): DocNavLink | undefined;
@@ -0,0 +1,255 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Facebook, Inc. and its affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.toNavigationLink = exports.toDocNavigationLink = exports.createSidebarsUtils = exports.collectSidebarsNavigations = exports.collectSidebarsDocIds = exports.collectSidebarNavigation = exports.collectSidebarDocIds = exports.collectSidebarLinks = exports.collectSidebarCategories = exports.collectSidebarDocItems = exports.transformSidebarItems = exports.isCategoriesShorthand = void 0;
10
+ const tslib_1 = require("tslib");
11
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
12
+ const utils_1 = require("@docusaurus/utils");
13
+ function isCategoriesShorthand(item) {
14
+ return typeof item === 'object' && !item.type;
15
+ }
16
+ exports.isCategoriesShorthand = isCategoriesShorthand;
17
+ function transformSidebarItems(sidebar, updateFn) {
18
+ function transformRecursive(item) {
19
+ if (item.type === 'category') {
20
+ return updateFn({
21
+ ...item,
22
+ items: item.items.map(transformRecursive),
23
+ });
24
+ }
25
+ return updateFn(item);
26
+ }
27
+ return sidebar.map(transformRecursive);
28
+ }
29
+ exports.transformSidebarItems = transformSidebarItems;
30
+ /**
31
+ * Flatten sidebar items into a single flat array (containing categories/docs on
32
+ * the same level). Order matters (useful for next/prev nav), top categories
33
+ * appear before their child elements
34
+ */
35
+ function flattenSidebarItems(items) {
36
+ function flattenRecursive(item) {
37
+ return item.type === 'category'
38
+ ? [item, ...item.items.flatMap(flattenRecursive)]
39
+ : [item];
40
+ }
41
+ return items.flatMap(flattenRecursive);
42
+ }
43
+ function collectSidebarItemsOfType(type, sidebar) {
44
+ return flattenSidebarItems(sidebar).filter((item) => item.type === type);
45
+ }
46
+ function collectSidebarDocItems(sidebar) {
47
+ return collectSidebarItemsOfType('doc', sidebar);
48
+ }
49
+ exports.collectSidebarDocItems = collectSidebarDocItems;
50
+ function collectSidebarCategories(sidebar) {
51
+ return collectSidebarItemsOfType('category', sidebar);
52
+ }
53
+ exports.collectSidebarCategories = collectSidebarCategories;
54
+ function collectSidebarLinks(sidebar) {
55
+ return collectSidebarItemsOfType('link', sidebar);
56
+ }
57
+ exports.collectSidebarLinks = collectSidebarLinks;
58
+ // /!\ docId order matters for navigation!
59
+ function collectSidebarDocIds(sidebar) {
60
+ return flattenSidebarItems(sidebar).flatMap((item) => {
61
+ if (item.type === 'category') {
62
+ return item.link?.type === 'doc' ? [item.link.id] : [];
63
+ }
64
+ if (item.type === 'doc') {
65
+ return [item.id];
66
+ }
67
+ return [];
68
+ });
69
+ }
70
+ exports.collectSidebarDocIds = collectSidebarDocIds;
71
+ function collectSidebarNavigation(sidebar) {
72
+ return flattenSidebarItems(sidebar).flatMap((item) => {
73
+ if (item.type === 'category' && item.link) {
74
+ return [item];
75
+ }
76
+ if (item.type === 'doc') {
77
+ return [item];
78
+ }
79
+ return [];
80
+ });
81
+ }
82
+ exports.collectSidebarNavigation = collectSidebarNavigation;
83
+ function collectSidebarsDocIds(sidebars) {
84
+ return lodash_1.default.mapValues(sidebars, collectSidebarDocIds);
85
+ }
86
+ exports.collectSidebarsDocIds = collectSidebarsDocIds;
87
+ function collectSidebarsNavigations(sidebars) {
88
+ return lodash_1.default.mapValues(sidebars, collectSidebarNavigation);
89
+ }
90
+ exports.collectSidebarsNavigations = collectSidebarsNavigations;
91
+ function createSidebarsUtils(sidebars) {
92
+ const sidebarNameToDocIds = collectSidebarsDocIds(sidebars);
93
+ const sidebarNameToNavigationItems = collectSidebarsNavigations(sidebars);
94
+ // Reverse mapping
95
+ const docIdToSidebarName = Object.fromEntries(Object.entries(sidebarNameToDocIds).flatMap(([sidebarName, docIds]) => docIds.map((docId) => [docId, sidebarName])));
96
+ function getFirstDocIdOfFirstSidebar() {
97
+ return Object.values(sidebarNameToDocIds)[0]?.[0];
98
+ }
99
+ function getSidebarNameByDocId(docId) {
100
+ return docIdToSidebarName[docId];
101
+ }
102
+ function emptySidebarNavigation() {
103
+ return {
104
+ sidebarName: undefined,
105
+ previous: undefined,
106
+ next: undefined,
107
+ };
108
+ }
109
+ function getDocNavigation(unversionedId, versionedId, displayedSidebar) {
110
+ // TODO legacy id retro-compatibility!
111
+ let docId = unversionedId;
112
+ let sidebarName = displayedSidebar === undefined
113
+ ? getSidebarNameByDocId(docId)
114
+ : displayedSidebar;
115
+ if (sidebarName === undefined) {
116
+ docId = versionedId;
117
+ sidebarName = getSidebarNameByDocId(docId);
118
+ }
119
+ if (!sidebarName) {
120
+ return emptySidebarNavigation();
121
+ }
122
+ const navigationItems = sidebarNameToNavigationItems[sidebarName];
123
+ if (!navigationItems) {
124
+ throw new Error(`Doc with ID ${docId} wants to display sidebar ${sidebarName} but a sidebar with this name doesn't exist`);
125
+ }
126
+ const currentItemIndex = navigationItems.findIndex((item) => {
127
+ if (item.type === 'doc') {
128
+ return item.id === docId;
129
+ }
130
+ if (item.type === 'category' && item.link.type === 'doc') {
131
+ return item.link.id === docId;
132
+ }
133
+ return false;
134
+ });
135
+ if (currentItemIndex === -1) {
136
+ return { sidebarName, next: undefined, previous: undefined };
137
+ }
138
+ return {
139
+ sidebarName,
140
+ previous: navigationItems[currentItemIndex - 1],
141
+ next: navigationItems[currentItemIndex + 1],
142
+ };
143
+ }
144
+ function getCategoryGeneratedIndexList() {
145
+ return Object.values(sidebarNameToNavigationItems)
146
+ .flat()
147
+ .flatMap((item) => {
148
+ if (item.type === 'category' && item.link.type === 'generated-index') {
149
+ return [item];
150
+ }
151
+ return [];
152
+ });
153
+ }
154
+ /**
155
+ * We identity the category generated index by its permalink (should be
156
+ * unique). More reliable than using object identity
157
+ */
158
+ function getCategoryGeneratedIndexNavigation(categoryGeneratedIndexPermalink) {
159
+ function isCurrentCategoryGeneratedIndexItem(item) {
160
+ return (item.type === 'category' &&
161
+ item.link?.type === 'generated-index' &&
162
+ item.link.permalink === categoryGeneratedIndexPermalink);
163
+ }
164
+ const sidebarName = Object.entries(sidebarNameToNavigationItems).find(([, navigationItems]) => navigationItems.find(isCurrentCategoryGeneratedIndexItem))[0];
165
+ const navigationItems = sidebarNameToNavigationItems[sidebarName];
166
+ const currentItemIndex = navigationItems.findIndex(isCurrentCategoryGeneratedIndexItem);
167
+ return {
168
+ sidebarName,
169
+ previous: navigationItems[currentItemIndex - 1],
170
+ next: navigationItems[currentItemIndex + 1],
171
+ };
172
+ }
173
+ function checkSidebarsDocIds(validDocIds, sidebarFilePath) {
174
+ const allSidebarDocIds = Object.values(sidebarNameToDocIds).flat();
175
+ const invalidSidebarDocIds = lodash_1.default.difference(allSidebarDocIds, validDocIds);
176
+ if (invalidSidebarDocIds.length > 0) {
177
+ throw new Error(`Invalid sidebar file at "${(0, utils_1.toMessageRelativeFilePath)(sidebarFilePath)}".
178
+ These sidebar document ids do not exist:
179
+ - ${invalidSidebarDocIds.sort().join('\n- ')}
180
+
181
+ Available document ids are:
182
+ - ${lodash_1.default.uniq(validDocIds).sort().join('\n- ')}`);
183
+ }
184
+ }
185
+ function getFirstLink(sidebar) {
186
+ for (const item of sidebar) {
187
+ if (item.type === 'doc') {
188
+ return {
189
+ type: 'doc',
190
+ id: item.id,
191
+ label: item.label ?? item.id,
192
+ };
193
+ }
194
+ else if (item.type === 'category') {
195
+ if (item.link?.type === 'doc') {
196
+ return {
197
+ type: 'doc',
198
+ id: item.link.id,
199
+ label: item.label,
200
+ };
201
+ }
202
+ else if (item.link?.type === 'generated-index') {
203
+ return {
204
+ type: 'generated-index',
205
+ permalink: item.link.permalink,
206
+ label: item.label,
207
+ };
208
+ }
209
+ const firstSubItem = getFirstLink(item.items);
210
+ if (firstSubItem) {
211
+ return firstSubItem;
212
+ }
213
+ }
214
+ }
215
+ return undefined;
216
+ }
217
+ return {
218
+ sidebars,
219
+ getFirstDocIdOfFirstSidebar,
220
+ getSidebarNameByDocId,
221
+ getDocNavigation,
222
+ getCategoryGeneratedIndexList,
223
+ getCategoryGeneratedIndexNavigation,
224
+ checkSidebarsDocIds,
225
+ getFirstLink: (id) => getFirstLink(sidebars[id]),
226
+ };
227
+ }
228
+ exports.createSidebarsUtils = createSidebarsUtils;
229
+ function toDocNavigationLink(doc) {
230
+ const { title, permalink, frontMatter: { pagination_label: paginationLabel, sidebar_label: sidebarLabel, }, } = doc;
231
+ return { title: paginationLabel ?? sidebarLabel ?? title, permalink };
232
+ }
233
+ exports.toDocNavigationLink = toDocNavigationLink;
234
+ function toNavigationLink(navigationItem, docsById) {
235
+ function getDocById(docId) {
236
+ const doc = docsById[docId];
237
+ if (!doc) {
238
+ throw new Error(`Can't create navigation link: no doc found with id=${docId}`);
239
+ }
240
+ return doc;
241
+ }
242
+ if (!navigationItem) {
243
+ return undefined;
244
+ }
245
+ if (navigationItem.type === 'category') {
246
+ return navigationItem.link.type === 'doc'
247
+ ? toDocNavigationLink(getDocById(navigationItem.link.id))
248
+ : {
249
+ title: navigationItem.label,
250
+ permalink: navigationItem.link.permalink,
251
+ };
252
+ }
253
+ return toDocNavigationLink(getDocById(navigationItem.id));
254
+ }
255
+ exports.toNavigationLink = toNavigationLink;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import type { NormalizedSidebars, CategoryMetadataFile } from './types';
8
+ export declare function validateSidebars(sidebars: {
9
+ [sidebarId: string]: unknown;
10
+ }): asserts sidebars is NormalizedSidebars;
11
+ export declare function validateCategoryMetadataFile(unsafeContent: unknown): CategoryMetadataFile;
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Facebook, Inc. and its affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.validateCategoryMetadataFile = exports.validateSidebars = void 0;
10
+ const utils_validation_1 = require("@docusaurus/utils-validation");
11
+ // NOTE: we don't add any default values during validation on purpose!
12
+ // Config types are exposed to users for typechecking and we use the same type
13
+ // in normalization
14
+ const sidebarItemBaseSchema = utils_validation_1.Joi.object({
15
+ className: utils_validation_1.Joi.string(),
16
+ customProps: utils_validation_1.Joi.object().unknown(),
17
+ });
18
+ const sidebarItemAutogeneratedSchema = sidebarItemBaseSchema.append({
19
+ type: 'autogenerated',
20
+ dirName: utils_validation_1.Joi.string()
21
+ .required()
22
+ .pattern(/^[^/](?:.*[^/])?$/)
23
+ .message('"dirName" must be a dir path relative to the docs folder root, and should not start or end with slash'),
24
+ });
25
+ const sidebarItemDocSchema = sidebarItemBaseSchema.append({
26
+ type: utils_validation_1.Joi.string().valid('doc', 'ref').required(),
27
+ id: utils_validation_1.Joi.string().required(),
28
+ label: utils_validation_1.Joi.string(),
29
+ });
30
+ const sidebarItemHtmlSchema = sidebarItemBaseSchema.append({
31
+ type: 'html',
32
+ value: utils_validation_1.Joi.string().required(),
33
+ defaultStyle: utils_validation_1.Joi.boolean(),
34
+ });
35
+ const sidebarItemLinkSchema = sidebarItemBaseSchema.append({
36
+ type: 'link',
37
+ href: utils_validation_1.URISchema.required(),
38
+ label: utils_validation_1.Joi.string()
39
+ .required()
40
+ .messages({ 'any.unknown': '"label" must be a string' }),
41
+ });
42
+ const sidebarItemCategoryLinkSchema = utils_validation_1.Joi.object()
43
+ .allow(null)
44
+ .when('.type', {
45
+ switch: [
46
+ {
47
+ is: 'doc',
48
+ then: utils_validation_1.Joi.object({
49
+ type: 'doc',
50
+ id: utils_validation_1.Joi.string().required(),
51
+ }),
52
+ },
53
+ {
54
+ is: 'generated-index',
55
+ then: utils_validation_1.Joi.object({
56
+ type: 'generated-index',
57
+ slug: utils_validation_1.Joi.string().optional(),
58
+ // This one is not in the user config, only in the normalized version
59
+ // permalink: Joi.string().optional(),
60
+ title: utils_validation_1.Joi.string().optional(),
61
+ description: utils_validation_1.Joi.string().optional(),
62
+ image: utils_validation_1.Joi.string().optional(),
63
+ keywords: [utils_validation_1.Joi.string(), utils_validation_1.Joi.array().items(utils_validation_1.Joi.string())],
64
+ }),
65
+ },
66
+ {
67
+ is: utils_validation_1.Joi.required(),
68
+ then: utils_validation_1.Joi.forbidden().messages({
69
+ 'any.unknown': 'Unknown sidebar category link type "{.type}".',
70
+ }),
71
+ },
72
+ ],
73
+ });
74
+ const sidebarItemCategorySchema = sidebarItemBaseSchema.append({
75
+ type: 'category',
76
+ label: utils_validation_1.Joi.string()
77
+ .required()
78
+ .messages({ 'any.unknown': '"label" must be a string' }),
79
+ items: utils_validation_1.Joi.array()
80
+ .required()
81
+ .messages({ 'any.unknown': '"items" must be an array' }),
82
+ // TODO: Joi doesn't allow mutual recursion. See https://github.com/sideway/joi/issues/2611
83
+ // .items(Joi.link('#sidebarItemSchema')),
84
+ link: sidebarItemCategoryLinkSchema,
85
+ collapsed: utils_validation_1.Joi.boolean().messages({
86
+ 'any.unknown': '"collapsed" must be a boolean',
87
+ }),
88
+ collapsible: utils_validation_1.Joi.boolean().messages({
89
+ 'any.unknown': '"collapsible" must be a boolean',
90
+ }),
91
+ });
92
+ const sidebarItemSchema = utils_validation_1.Joi.object().when('.type', {
93
+ switch: [
94
+ { is: 'link', then: sidebarItemLinkSchema },
95
+ {
96
+ is: utils_validation_1.Joi.string().valid('doc', 'ref').required(),
97
+ then: sidebarItemDocSchema,
98
+ },
99
+ { is: 'html', then: sidebarItemHtmlSchema },
100
+ { is: 'autogenerated', then: sidebarItemAutogeneratedSchema },
101
+ { is: 'category', then: sidebarItemCategorySchema },
102
+ {
103
+ is: utils_validation_1.Joi.any().required(),
104
+ then: utils_validation_1.Joi.forbidden().messages({
105
+ 'any.unknown': 'Unknown sidebar item type "{.type}".',
106
+ }),
107
+ },
108
+ ],
109
+ });
110
+ // .id('sidebarItemSchema');
111
+ function validateSidebarItem(item) {
112
+ // TODO: remove once with proper Joi support
113
+ // Because we can't use Joi to validate nested items (see above), we do it
114
+ // manually
115
+ utils_validation_1.Joi.assert(item, sidebarItemSchema);
116
+ if (item.type === 'category') {
117
+ item.items.forEach(validateSidebarItem);
118
+ }
119
+ }
120
+ function validateSidebars(sidebars) {
121
+ Object.values(sidebars).forEach((sidebar) => {
122
+ sidebar.forEach(validateSidebarItem);
123
+ });
124
+ }
125
+ exports.validateSidebars = validateSidebars;
126
+ const categoryMetadataFileSchema = utils_validation_1.Joi.object({
127
+ label: utils_validation_1.Joi.string(),
128
+ position: utils_validation_1.Joi.number(),
129
+ collapsed: utils_validation_1.Joi.boolean(),
130
+ collapsible: utils_validation_1.Joi.boolean(),
131
+ className: utils_validation_1.Joi.string(),
132
+ link: sidebarItemCategoryLinkSchema,
133
+ customProps: utils_validation_1.Joi.object().unknown(),
134
+ });
135
+ function validateCategoryMetadataFile(unsafeContent) {
136
+ return utils_validation_1.Joi.attempt(unsafeContent, categoryMetadataFileSchema);
137
+ }
138
+ exports.validateCategoryMetadataFile = validateCategoryMetadataFile;
package/lib/slug.d.ts CHANGED
@@ -4,11 +4,13 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import { NumberPrefixParser } from './types';
8
- export default function getSlug({ baseID, frontmatterSlug, dirName, stripDirNumberPrefixes, numberPrefixParser, }: {
7
+ import type { DocMetadataBase } from './types';
8
+ import type { NumberPrefixParser } from '@docusaurus/plugin-content-docs';
9
+ export default function getSlug({ baseID, frontMatterSlug, source, sourceDirName, stripDirNumberPrefixes, numberPrefixParser, }: {
9
10
  baseID: string;
10
- frontmatterSlug?: string;
11
- dirName: string;
11
+ frontMatterSlug?: string;
12
+ source: DocMetadataBase['source'];
13
+ sourceDirName: DocMetadataBase['sourceDirName'];
12
14
  stripDirNumberPrefixes?: boolean;
13
15
  numberPrefixParser?: NumberPrefixParser;
14
16
  }): string;