@azerion/bunosaurus-plugin-content-docs 0.0.0-stage → 4.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 (119) hide show
  1. package/README.md +6 -2
  2. package/lib/categoryGeneratedIndex.d.ts +12 -0
  3. package/lib/categoryGeneratedIndex.js +36 -0
  4. package/lib/cli.d.ts +13 -0
  5. package/lib/cli.js +124 -0
  6. package/lib/client/doc.d.ts +29 -0
  7. package/lib/client/doc.js +47 -0
  8. package/lib/client/docSidebarItemsExpandedState.d.ts +30 -0
  9. package/lib/client/docSidebarItemsExpandedState.js +27 -0
  10. package/lib/client/docsClientUtils.d.ts +15 -0
  11. package/lib/client/docsClientUtils.js +86 -0
  12. package/lib/client/docsPreferredVersion.d.ts +29 -0
  13. package/lib/client/docsPreferredVersion.js +124 -0
  14. package/lib/client/docsSearch.d.ts +19 -0
  15. package/lib/client/docsSearch.js +39 -0
  16. package/lib/client/docsSidebar.d.ts +25 -0
  17. package/lib/client/docsSidebar.js +29 -0
  18. package/lib/client/docsUtils.d.ts +112 -0
  19. package/lib/client/docsUtils.js +299 -0
  20. package/lib/client/docsVersion.d.ts +19 -0
  21. package/lib/client/docsVersion.js +25 -0
  22. package/lib/client/index.d.ts +91 -0
  23. package/lib/client/index.js +83 -0
  24. package/lib/client/structuredDataUtils.d.ts +11 -0
  25. package/lib/client/structuredDataUtils.js +35 -0
  26. package/lib/constants.d.ts +14 -0
  27. package/lib/constants.js +17 -0
  28. package/lib/contentHelpers.d.ts +12 -0
  29. package/lib/contentHelpers.js +31 -0
  30. package/lib/docs.d.ts +48 -0
  31. package/lib/docs.js +252 -0
  32. package/lib/frontMatter.d.ts +10 -0
  33. package/lib/frontMatter.js +46 -0
  34. package/lib/globalData.d.ts +9 -0
  35. package/lib/globalData.js +59 -0
  36. package/lib/index.d.ts +10 -0
  37. package/lib/index.js +198 -0
  38. package/lib/numberPrefix.d.ts +11 -0
  39. package/lib/numberPrefix.js +50 -0
  40. package/lib/options.d.ts +10 -0
  41. package/lib/options.js +138 -0
  42. package/lib/props.d.ts +21 -0
  43. package/lib/props.js +156 -0
  44. package/lib/routes.d.ts +22 -0
  45. package/lib/routes.js +184 -0
  46. package/lib/server-export.d.ts +9 -0
  47. package/lib/server-export.js +25 -0
  48. package/lib/sidebars/generator.d.ts +10 -0
  49. package/lib/sidebars/generator.js +217 -0
  50. package/lib/sidebars/index.d.ts +13 -0
  51. package/lib/sidebars/index.js +99 -0
  52. package/lib/sidebars/normalization.d.ts +13 -0
  53. package/lib/sidebars/normalization.js +58 -0
  54. package/lib/sidebars/postProcessor.d.ts +11 -0
  55. package/lib/sidebars/postProcessor.js +82 -0
  56. package/lib/sidebars/processor.d.ts +10 -0
  57. package/lib/sidebars/processor.js +77 -0
  58. package/lib/sidebars/types.d.ts +192 -0
  59. package/lib/sidebars/types.js +8 -0
  60. package/lib/sidebars/utils.d.ts +69 -0
  61. package/lib/sidebars/utils.js +327 -0
  62. package/lib/sidebars/validation.d.ts +11 -0
  63. package/lib/sidebars/validation.js +152 -0
  64. package/lib/slug.d.ts +15 -0
  65. package/lib/slug.js +51 -0
  66. package/lib/translations.d.ts +10 -0
  67. package/lib/translations.js +243 -0
  68. package/lib/types.d.ts +27 -0
  69. package/lib/types.js +8 -0
  70. package/lib/versions/files.d.ts +54 -0
  71. package/lib/versions/files.js +152 -0
  72. package/lib/versions/loadVersion.d.ts +17 -0
  73. package/lib/versions/loadVersion.js +126 -0
  74. package/lib/versions/validation.d.ts +17 -0
  75. package/lib/versions/validation.js +70 -0
  76. package/lib/versions/version.d.ts +40 -0
  77. package/lib/versions/version.js +189 -0
  78. package/package.json +70 -4
  79. package/src/categoryGeneratedIndex.ts +60 -0
  80. package/src/cli.ts +180 -0
  81. package/src/client/doc.tsx +71 -0
  82. package/src/client/docSidebarItemsExpandedState.tsx +55 -0
  83. package/src/client/docsClientUtils.ts +140 -0
  84. package/src/client/docsPreferredVersion.tsx +245 -0
  85. package/src/client/docsSearch.test.ts +15 -0
  86. package/src/client/docsSearch.ts +57 -0
  87. package/src/client/docsSidebar.tsx +50 -0
  88. package/src/client/docsUtils.tsx +442 -0
  89. package/src/client/docsVersion.tsx +36 -0
  90. package/src/client/index.ts +211 -0
  91. package/src/client/structuredDataUtils.ts +54 -0
  92. package/src/constants.ts +15 -0
  93. package/src/contentHelpers.ts +34 -0
  94. package/src/docs.ts +402 -0
  95. package/src/frontMatter.ts +57 -0
  96. package/src/globalData.ts +79 -0
  97. package/src/index.ts +289 -0
  98. package/src/numberPrefix.ts +62 -0
  99. package/src/options.ts +185 -0
  100. package/src/plugin-content-docs.d.ts +667 -0
  101. package/src/props.ts +223 -0
  102. package/src/routes.ts +263 -0
  103. package/src/server-export.ts +26 -0
  104. package/src/sidebars/README.md +10 -0
  105. package/src/sidebars/generator.ts +307 -0
  106. package/src/sidebars/index.ts +130 -0
  107. package/src/sidebars/normalization.ts +91 -0
  108. package/src/sidebars/postProcessor.ts +115 -0
  109. package/src/sidebars/processor.ts +122 -0
  110. package/src/sidebars/types.ts +293 -0
  111. package/src/sidebars/utils.ts +529 -0
  112. package/src/sidebars/validation.ts +189 -0
  113. package/src/slug.ts +79 -0
  114. package/src/translations.ts +365 -0
  115. package/src/types.ts +34 -0
  116. package/src/versions/files.ts +240 -0
  117. package/src/versions/loadVersion.ts +185 -0
  118. package/src/versions/validation.ts +115 -0
  119. package/src/versions/version.ts +300 -0
@@ -0,0 +1,82 @@
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.postProcessSidebars = postProcessSidebars;
10
+ const tslib_1 = require("tslib");
11
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
12
+ const utils_1 = require("@docusaurus/utils");
13
+ function normalizeCategoryLink(category, params) {
14
+ if (category.link?.type === 'doc' && params.draftIds.has(category.link.id)) {
15
+ return undefined;
16
+ }
17
+ if (category.link?.type === 'generated-index') {
18
+ // Default slug logic can be improved
19
+ const getDefaultSlug = () => `/category/${params.categoryLabelSlugger.slug(category.label)}`;
20
+ const slug = category.link.slug ?? getDefaultSlug();
21
+ const permalink = (0, utils_1.normalizeUrl)([params.version.path, slug]);
22
+ return {
23
+ ...category.link,
24
+ slug,
25
+ permalink,
26
+ };
27
+ }
28
+ return category.link;
29
+ }
30
+ function postProcessSidebarItem(item, params) {
31
+ if (item.type === 'category') {
32
+ // Fail-fast if there's actually no subitems, no because all subitems are
33
+ // drafts. This is likely a configuration mistake.
34
+ if (item.items.length === 0 && !item.link) {
35
+ throw new Error(`Sidebar category ${item.label} has neither any subitem nor a link. This makes this item not able to link to anything.`);
36
+ }
37
+ const category = {
38
+ ...item,
39
+ collapsed: item.collapsed ?? params.sidebarOptions.sidebarCollapsed,
40
+ collapsible: item.collapsible ?? params.sidebarOptions.sidebarCollapsible,
41
+ link: normalizeCategoryLink(item, params),
42
+ items: item.items
43
+ .map((subItem) => postProcessSidebarItem(subItem, params))
44
+ .filter((v) => Boolean(v)),
45
+ };
46
+ // If the current category doesn't have subitems, we render a normal link
47
+ // instead.
48
+ if (category.items.length === 0) {
49
+ // Doesn't make sense to render an empty generated index page, so we
50
+ // filter the entire category out as well.
51
+ if (!category.link ||
52
+ category.link.type === 'generated-index' ||
53
+ params.draftIds.has(category.link.id)) {
54
+ return null;
55
+ }
56
+ const { label, className, customProps } = category;
57
+ return {
58
+ type: 'doc',
59
+ id: category.link.id,
60
+ label,
61
+ ...(className && { className }),
62
+ ...(customProps && { customProps }),
63
+ };
64
+ }
65
+ // A non-collapsible category can't be collapsed!
66
+ if (!category.collapsible) {
67
+ category.collapsed = false;
68
+ }
69
+ return category;
70
+ }
71
+ if ((item.type === 'doc' || item.type === 'ref') &&
72
+ params.draftIds.has(item.id)) {
73
+ return null;
74
+ }
75
+ return item;
76
+ }
77
+ function postProcessSidebars(sidebars, params) {
78
+ const draftIds = new Set(params.drafts.map((d) => d.id));
79
+ return lodash_1.default.mapValues(sidebars, (sidebar) => sidebar
80
+ .map((item) => postProcessSidebarItem(item, { ...params, draftIds }))
81
+ .filter((v) => Boolean(v)));
82
+ }
@@ -0,0 +1,10 @@
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, ProcessedSidebars, SidebarProcessorParams, CategoryMetadataFile } from './types';
8
+ export declare function processSidebars(unprocessedSidebars: NormalizedSidebars, categoriesMetadata: {
9
+ [filePath: string]: CategoryMetadataFile;
10
+ }, params: SidebarProcessorParams): Promise<ProcessedSidebars>;
@@ -0,0 +1,77 @@
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.processSidebars = processSidebars;
10
+ const tslib_1 = require("tslib");
11
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
12
+ const combine_promises_1 = tslib_1.__importDefault(require("combine-promises"));
13
+ const generator_1 = require("./generator");
14
+ const validation_1 = require("./validation");
15
+ const docs_1 = require("../docs");
16
+ function toSidebarItemsGeneratorDoc(doc) {
17
+ return lodash_1.default.pick(doc, [
18
+ 'id',
19
+ 'title',
20
+ 'frontMatter',
21
+ 'source',
22
+ 'sourceDirName',
23
+ 'sidebarPosition',
24
+ ]);
25
+ }
26
+ function toSidebarItemsGeneratorVersion(version) {
27
+ return lodash_1.default.pick(version, ['versionName', 'contentPath']);
28
+ }
29
+ // Handle the generation of autogenerated sidebar items and other
30
+ // post-processing checks
31
+ async function processSidebar(unprocessedSidebar, categoriesMetadata, params) {
32
+ const { sidebarItemsGenerator, numberPrefixParser, docs, version } = params;
33
+ // Just a minor lazy transformation optimization
34
+ const getSidebarItemsGeneratorDocsAndVersion = lodash_1.default.memoize(() => ({
35
+ docs: docs.map(toSidebarItemsGeneratorDoc),
36
+ version: toSidebarItemsGeneratorVersion(version),
37
+ }));
38
+ async function processAutoGeneratedItem(item) {
39
+ const generatedItems = await sidebarItemsGenerator({
40
+ item,
41
+ numberPrefixParser,
42
+ defaultSidebarItemsGenerator: generator_1.DefaultSidebarItemsGenerator,
43
+ isCategoryIndex: docs_1.isCategoryIndex,
44
+ ...getSidebarItemsGeneratorDocsAndVersion(),
45
+ categoriesMetadata,
46
+ });
47
+ // Process again... weird but sidebar item generated might generate some
48
+ // auto-generated items?
49
+ // TODO repeatedly process & unwrap autogenerated items until there are no
50
+ // more autogenerated items, or when loop count (e.g. 10) is reached
51
+ return processItems(generatedItems);
52
+ }
53
+ async function processItem(item) {
54
+ if (item.type === 'category') {
55
+ return [
56
+ {
57
+ ...item,
58
+ items: (await Promise.all(item.items.map(processItem))).flat(),
59
+ },
60
+ ];
61
+ }
62
+ if (item.type === 'autogenerated') {
63
+ return processAutoGeneratedItem(item);
64
+ }
65
+ return [item];
66
+ }
67
+ async function processItems(items) {
68
+ return (await Promise.all(items.map(processItem))).flat();
69
+ }
70
+ const processedSidebar = await processItems(unprocessedSidebar);
71
+ return processedSidebar;
72
+ }
73
+ async function processSidebars(unprocessedSidebars, categoriesMetadata, params) {
74
+ const processedSidebars = await (0, combine_promises_1.default)(lodash_1.default.mapValues(unprocessedSidebars, (unprocessedSidebar) => processSidebar(unprocessedSidebar, categoriesMetadata, params)));
75
+ (0, validation_1.validateSidebars)(processedSidebars);
76
+ return processedSidebars;
77
+ }
@@ -0,0 +1,192 @@
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 { NumberPrefixParser, SidebarOptions, CategoryIndexMatcher, DocMetadataBase, VersionMetadata } from '@docusaurus/plugin-content-docs';
9
+ import type { Slugger } from '@docusaurus/utils';
10
+ type Expand<T extends {
11
+ [x: string]: unknown;
12
+ }> = {
13
+ [P in keyof T]: T[P];
14
+ };
15
+ export type SidebarItemBase = {
16
+ key?: string;
17
+ className?: string;
18
+ customProps?: {
19
+ [key: string]: unknown;
20
+ };
21
+ };
22
+ export type SidebarItemDoc = SidebarItemBase & {
23
+ type: 'doc' | 'ref';
24
+ label?: string;
25
+ id: string;
26
+ /**
27
+ * This is an internal marker set during the sidebar normalization process.
28
+ * Docs with labels defined in the config need to be translated with JSON.
29
+ * Otherwise, it's preferable to translate the MDX doc title or front matter.
30
+ */
31
+ translatable?: true;
32
+ };
33
+ export type SidebarItemHtml = SidebarItemBase & {
34
+ type: 'html';
35
+ value: string;
36
+ defaultStyle?: boolean;
37
+ };
38
+ export type SidebarItemLink = SidebarItemBase & {
39
+ type: 'link';
40
+ href: string;
41
+ label: string;
42
+ autoAddBaseUrl?: boolean;
43
+ description?: string;
44
+ };
45
+ export type SidebarItemAutogenerated = SidebarItemBase & {
46
+ type: 'autogenerated';
47
+ dirName: string;
48
+ };
49
+ type SidebarItemCategoryBase = SidebarItemBase & {
50
+ type: 'category';
51
+ label: string;
52
+ collapsed: boolean;
53
+ collapsible: boolean;
54
+ description?: string;
55
+ };
56
+ export type SidebarItemCategoryLinkDoc = {
57
+ type: 'doc';
58
+ id: string;
59
+ };
60
+ export type SidebarItemCategoryLinkGeneratedIndexConfig = {
61
+ type: 'generated-index';
62
+ slug?: string;
63
+ title?: string;
64
+ description?: string;
65
+ image?: string;
66
+ keywords?: string | readonly string[];
67
+ };
68
+ export type SidebarItemCategoryLinkGeneratedIndex = {
69
+ type: 'generated-index';
70
+ slug: string;
71
+ permalink: string;
72
+ title?: string;
73
+ description?: string;
74
+ image?: string;
75
+ keywords?: string | readonly string[];
76
+ };
77
+ export type SidebarItemCategoryLinkConfig = SidebarItemCategoryLinkDoc | SidebarItemCategoryLinkGeneratedIndexConfig;
78
+ export type SidebarItemCategoryLink = SidebarItemCategoryLinkDoc | SidebarItemCategoryLinkGeneratedIndex;
79
+ export type SidebarItemCategoryConfig = Expand<Optional<SidebarItemCategoryBase, 'collapsed' | 'collapsible'> & {
80
+ items: SidebarCategoriesShorthand | SidebarItemConfig[];
81
+ link?: SidebarItemCategoryLinkConfig;
82
+ }>;
83
+ export type SidebarCategoriesShorthand = {
84
+ [sidebarCategory: string]: SidebarCategoriesShorthand | SidebarItemConfig[];
85
+ };
86
+ export type SidebarItemConfig = Omit<SidebarItemDoc, 'translatable'> | SidebarItemHtml | SidebarItemLink | SidebarItemAutogenerated | SidebarItemCategoryConfig | string | SidebarCategoriesShorthand;
87
+ export type SidebarConfig = SidebarCategoriesShorthand | SidebarItemConfig[];
88
+ export type SidebarsConfig = {
89
+ [sidebarId: string]: SidebarConfig;
90
+ };
91
+ export type NormalizedSidebarItemCategory = Expand<Optional<SidebarItemCategoryBase, 'collapsed' | 'collapsible'> & {
92
+ items: NormalizedSidebarItem[];
93
+ link?: SidebarItemCategoryLinkConfig;
94
+ }>;
95
+ export type NormalizedSidebarItem = SidebarItemDoc | SidebarItemHtml | SidebarItemLink | NormalizedSidebarItemCategory | SidebarItemAutogenerated;
96
+ export type NormalizedSidebar = NormalizedSidebarItem[];
97
+ export type NormalizedSidebars = {
98
+ [sidebarId: string]: NormalizedSidebar;
99
+ };
100
+ export type ProcessedSidebarItemCategory = Expand<Optional<SidebarItemCategoryBase, 'collapsed' | 'collapsible'> & {
101
+ items: ProcessedSidebarItem[];
102
+ link?: SidebarItemCategoryLinkConfig;
103
+ }>;
104
+ export type ProcessedSidebarItem = SidebarItemDoc | SidebarItemHtml | SidebarItemLink | ProcessedSidebarItemCategory;
105
+ export type ProcessedSidebar = ProcessedSidebarItem[];
106
+ export type ProcessedSidebars = {
107
+ [sidebarId: string]: ProcessedSidebar;
108
+ };
109
+ export type SidebarItemCategory = Expand<SidebarItemCategoryBase & {
110
+ items: SidebarItem[];
111
+ link?: SidebarItemCategoryLink;
112
+ }>;
113
+ export type SidebarItemCategoryWithLink = Required<SidebarItemCategory, 'link'>;
114
+ export type SidebarItemCategoryWithGeneratedIndex = SidebarItemCategoryWithLink & {
115
+ link: SidebarItemCategoryLinkGeneratedIndex;
116
+ };
117
+ export type SidebarItem = SidebarItemDoc | SidebarItemHtml | SidebarItemLink | SidebarItemCategory;
118
+ export type SidebarNavigationItem = SidebarItemDoc | SidebarItemCategoryWithLink;
119
+ export type Sidebar = SidebarItem[];
120
+ export type SidebarItemType = SidebarItem['type'];
121
+ export type Sidebars = {
122
+ [sidebarId: string]: Sidebar;
123
+ };
124
+ export type PropSidebarItemCategory = Expand<SidebarItemCategoryBase & {
125
+ items: PropSidebarItem[];
126
+ href?: string;
127
+ linkUnlisted?: boolean;
128
+ }>;
129
+ export type PropSidebarItemLink = SidebarItemLink & {
130
+ docId?: string;
131
+ unlisted?: boolean;
132
+ };
133
+ export type PropSidebarItemHtml = SidebarItemHtml;
134
+ export type PropSidebarItem = PropSidebarItemLink | PropSidebarItemCategory | PropSidebarItemHtml;
135
+ export type PropSidebar = PropSidebarItem[];
136
+ export type PropSidebars = {
137
+ [sidebarId: string]: PropSidebar;
138
+ };
139
+ export type PropSidebarBreadcrumbsItem = PropSidebarItemLink | PropSidebarItemCategory;
140
+ export type CategoryMetadataFile = {
141
+ key?: string;
142
+ label?: string;
143
+ position?: number;
144
+ description?: string;
145
+ collapsed?: boolean;
146
+ collapsible?: boolean;
147
+ className?: string;
148
+ link?: SidebarItemCategoryLinkConfig | null;
149
+ customProps?: {
150
+ [key: string]: unknown;
151
+ };
152
+ };
153
+ export type SidebarItemsGeneratorDoc = Pick<DocMetadataBase, 'id' | 'title' | 'frontMatter' | 'source' | 'sourceDirName' | 'sidebarPosition'>;
154
+ export type SidebarItemsGeneratorVersion = Pick<VersionMetadata, 'versionName' | 'contentPath'>;
155
+ export type SidebarItemsGeneratorArgs = {
156
+ /** The sidebar item with type "autogenerated" to be transformed. */
157
+ item: SidebarItemAutogenerated;
158
+ /** Useful metadata for the version this sidebar belongs to. */
159
+ version: SidebarItemsGeneratorVersion;
160
+ /** All the docs of that version (unfiltered). */
161
+ docs: SidebarItemsGeneratorDoc[];
162
+ /** Number prefix parser configured for this plugin. */
163
+ numberPrefixParser: NumberPrefixParser;
164
+ /** The default category index matcher which you can override. */
165
+ isCategoryIndex: CategoryIndexMatcher;
166
+ /**
167
+ * Key is the path relative to the doc content directory, value is the
168
+ * category metadata file's content.
169
+ */
170
+ categoriesMetadata: {
171
+ [filePath: string]: CategoryMetadataFile;
172
+ };
173
+ };
174
+ export type SidebarItemsGenerator = (generatorArgs: SidebarItemsGeneratorArgs) => NormalizedSidebar | Promise<NormalizedSidebar>;
175
+ export type SidebarItemsGeneratorOption = (generatorArgs: {
176
+ /**
177
+ * Useful to re-use/enhance the default sidebar generation logic from
178
+ * Docusaurus.
179
+ * @see https://github.com/facebook/docusaurus/issues/4640#issuecomment-822292320
180
+ */
181
+ defaultSidebarItemsGenerator: SidebarItemsGenerator;
182
+ } & SidebarItemsGeneratorArgs) => NormalizedSidebar | Promise<NormalizedSidebar>;
183
+ export type SidebarProcessorParams = {
184
+ sidebarItemsGenerator: SidebarItemsGeneratorOption;
185
+ numberPrefixParser: NumberPrefixParser;
186
+ docs: DocMetadataBase[];
187
+ drafts: DocMetadataBase[];
188
+ version: VersionMetadata;
189
+ categoryLabelSlugger: Slugger;
190
+ sidebarOptions: SidebarOptions;
191
+ };
192
+ export {};
@@ -0,0 +1,8 @@
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 });
@@ -0,0 +1,69 @@
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, PropNavigationLink, VersionMetadata } from '@docusaurus/plugin-content-docs';
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 collectSidebarRefs(sidebar: Sidebar): SidebarItemDoc[];
15
+ export declare function collectSidebarDocIds(sidebar: Sidebar): string[];
16
+ export declare function collectSidebarNavigation(sidebar: Sidebar): SidebarNavigationItem[];
17
+ export declare function collectSidebarsDocIds(sidebars: Sidebars): {
18
+ [sidebarId: string]: string[];
19
+ };
20
+ export declare function collectSidebarsNavigations(sidebars: Sidebars): {
21
+ [sidebarId: string]: SidebarNavigationItem[];
22
+ };
23
+ export type SidebarNavigation = {
24
+ sidebarName: string | undefined;
25
+ previous: SidebarNavigationItem | undefined;
26
+ next: SidebarNavigationItem | undefined;
27
+ };
28
+ export type SidebarsUtils = {
29
+ sidebars: Sidebars;
30
+ getFirstDocIdOfFirstSidebar: () => string | undefined;
31
+ getSidebarNameByDocId: (docId: string) => string | undefined;
32
+ getDocNavigation: (params: {
33
+ docId: string;
34
+ displayedSidebar: string | null | undefined;
35
+ unlistedIds: Set<string>;
36
+ }) => SidebarNavigation;
37
+ getCategoryGeneratedIndexList: () => SidebarItemCategoryWithGeneratedIndex[];
38
+ getCategoryGeneratedIndexNavigation: (categoryGeneratedIndexPermalink: string) => SidebarNavigation;
39
+ /**
40
+ * This function may return undefined. This is usually a user mistake, because
41
+ * it means this sidebar will never be displayed; however, we can still use
42
+ * `displayed_sidebar` to make it displayed. Pretty weird but valid use-case
43
+ */
44
+ getFirstLink: (sidebarId: string) => {
45
+ type: 'doc';
46
+ id: string;
47
+ label: string;
48
+ } | {
49
+ type: 'generated-index';
50
+ permalink: string;
51
+ label: string;
52
+ } | undefined;
53
+ checkLegacyVersionedSidebarNames: ({ versionMetadata, }: {
54
+ sidebarFilePath: string;
55
+ versionMetadata: VersionMetadata;
56
+ }) => void;
57
+ checkSidebarsDocIds: ({ allDocIds, sidebarFilePath, versionMetadata, }: {
58
+ allDocIds: string[];
59
+ sidebarFilePath: string;
60
+ versionMetadata: VersionMetadata;
61
+ }) => void;
62
+ };
63
+ export declare function createSidebarsUtils(sidebars: Sidebars): SidebarsUtils;
64
+ export declare function toDocNavigationLink(doc: DocMetadataBase, options?: {
65
+ sidebarItemLabel?: string;
66
+ }): PropNavigationLink;
67
+ export declare function toNavigationLink(navigationItem: SidebarNavigationItem | undefined, docsById: {
68
+ [docId: string]: DocMetadataBase;
69
+ }): PropNavigationLink | undefined;