@docusaurus/plugin-content-docs 0.0.0-4356 → 0.0.0-4364
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.
- package/lib/categoryGeneratedIndex.js +2 -0
- package/lib/globalData.d.ts +3 -1
- package/lib/globalData.js +23 -1
- package/lib/routes.js +3 -1
- package/lib/sidebars/types.d.ts +4 -0
- package/lib/sidebars/utils.d.ts +9 -0
- package/lib/sidebars/utils.js +37 -0
- package/lib/sidebars/validation.js +2 -0
- package/lib/types.d.ts +10 -0
- package/package.json +9 -9
- package/src/categoryGeneratedIndex.ts +2 -0
- package/src/globalData.ts +31 -0
- package/src/plugin-content-docs.d.ts +4 -1
- package/src/routes.ts +13 -2
- package/src/sidebars/types.ts +4 -0
- package/src/sidebars/utils.ts +57 -0
- package/src/sidebars/validation.ts +2 -0
- package/src/types.ts +13 -0
|
@@ -18,6 +18,8 @@ function getCategoryGeneratedIndexMetadata({ category, sidebarsUtils, docsById,
|
|
|
18
18
|
return {
|
|
19
19
|
title: (_a = category.link.title) !== null && _a !== void 0 ? _a : category.label,
|
|
20
20
|
description: category.link.description,
|
|
21
|
+
image: category.link.image,
|
|
22
|
+
keywords: category.link.keywords,
|
|
21
23
|
slug: category.link.slug,
|
|
22
24
|
permalink: category.link.permalink,
|
|
23
25
|
sidebar: sidebarName,
|
package/lib/globalData.d.ts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
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 type {
|
|
7
|
+
import type { Sidebars } from './sidebars/types';
|
|
8
|
+
import type { DocMetadata, GlobalDoc, LoadedVersion, GlobalVersion, GlobalSidebar } from './types';
|
|
8
9
|
export declare function toGlobalDataDoc(doc: DocMetadata): GlobalDoc;
|
|
10
|
+
export declare function toGlobalSidebars(sidebars: Sidebars, version: LoadedVersion): Record<string, GlobalSidebar>;
|
|
9
11
|
export declare function toGlobalDataVersion(version: LoadedVersion): GlobalVersion;
|
package/lib/globalData.js
CHANGED
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.toGlobalDataVersion = exports.toGlobalDataDoc = void 0;
|
|
9
|
+
exports.toGlobalDataVersion = exports.toGlobalSidebars = exports.toGlobalDataDoc = void 0;
|
|
10
|
+
const lodash_1 = require("lodash");
|
|
11
|
+
const utils_1 = require("@docusaurus/utils");
|
|
12
|
+
const utils_2 = require("./sidebars/utils");
|
|
10
13
|
function toGlobalDataDoc(doc) {
|
|
11
14
|
return {
|
|
12
15
|
id: doc.unversionedId,
|
|
@@ -15,6 +18,24 @@ function toGlobalDataDoc(doc) {
|
|
|
15
18
|
};
|
|
16
19
|
}
|
|
17
20
|
exports.toGlobalDataDoc = toGlobalDataDoc;
|
|
21
|
+
function toGlobalSidebars(sidebars, version) {
|
|
22
|
+
const { getFirstLink } = (0, utils_2.createSidebarsUtils)(sidebars);
|
|
23
|
+
return (0, lodash_1.mapValues)(sidebars, (sidebar, sidebarId) => {
|
|
24
|
+
const firstLink = getFirstLink(sidebarId);
|
|
25
|
+
if (!firstLink) {
|
|
26
|
+
return {};
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
link: {
|
|
30
|
+
path: firstLink.type === 'generated-index'
|
|
31
|
+
? (0, utils_1.normalizeUrl)([version.versionPath, firstLink.slug])
|
|
32
|
+
: version.docs.find((doc) => doc.id === firstLink.id || doc.unversionedId === firstLink.id).permalink,
|
|
33
|
+
label: firstLink.label,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
exports.toGlobalSidebars = toGlobalSidebars;
|
|
18
39
|
function toGlobalDataVersion(version) {
|
|
19
40
|
return {
|
|
20
41
|
name: version.versionName,
|
|
@@ -23,6 +44,7 @@ function toGlobalDataVersion(version) {
|
|
|
23
44
|
path: version.versionPath,
|
|
24
45
|
mainDocId: version.mainDocId,
|
|
25
46
|
docs: version.docs.map(toGlobalDataDoc),
|
|
47
|
+
sidebars: toGlobalSidebars(version.sidebars, version),
|
|
26
48
|
};
|
|
27
49
|
}
|
|
28
50
|
exports.toGlobalDataVersion = toGlobalDataVersion;
|
package/lib/routes.js
CHANGED
|
@@ -14,13 +14,15 @@ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
|
|
|
14
14
|
async function createCategoryGeneratedIndexRoutes({ version, actions, docCategoryGeneratedIndexComponent, }) {
|
|
15
15
|
const slugs = (0, utils_1.createSlugger)();
|
|
16
16
|
async function createCategoryGeneratedIndexRoute(categoryGeneratedIndex) {
|
|
17
|
-
const { sidebar, title, description, slug, permalink, previous, next } = categoryGeneratedIndex;
|
|
17
|
+
const { sidebar, title, description, slug, permalink, previous, next, image, keywords, } = categoryGeneratedIndex;
|
|
18
18
|
const propFileName = slugs.slug(`${version.versionPath}-${categoryGeneratedIndex.sidebar}-category-${categoryGeneratedIndex.title}`);
|
|
19
19
|
const prop = {
|
|
20
20
|
title,
|
|
21
21
|
description,
|
|
22
22
|
slug,
|
|
23
23
|
permalink,
|
|
24
|
+
image,
|
|
25
|
+
keywords,
|
|
24
26
|
navigation: {
|
|
25
27
|
previous,
|
|
26
28
|
next,
|
package/lib/sidebars/types.d.ts
CHANGED
|
@@ -42,6 +42,8 @@ export declare type SidebarItemCategoryLinkGeneratedIndexConfig = {
|
|
|
42
42
|
slug?: string;
|
|
43
43
|
title?: string;
|
|
44
44
|
description?: string;
|
|
45
|
+
image?: string;
|
|
46
|
+
keywords?: string | readonly string[];
|
|
45
47
|
};
|
|
46
48
|
export declare type SidebarItemCategoryLinkGeneratedIndex = {
|
|
47
49
|
type: 'generated-index';
|
|
@@ -49,6 +51,8 @@ export declare type SidebarItemCategoryLinkGeneratedIndex = {
|
|
|
49
51
|
permalink: string;
|
|
50
52
|
title?: string;
|
|
51
53
|
description?: string;
|
|
54
|
+
image?: string;
|
|
55
|
+
keywords?: string | readonly string[];
|
|
52
56
|
};
|
|
53
57
|
export declare type SidebarItemCategoryLinkConfig = SidebarItemCategoryLinkDoc | SidebarItemCategoryLinkGeneratedIndexConfig;
|
|
54
58
|
export declare type SidebarItemCategoryLink = SidebarItemCategoryLinkDoc | SidebarItemCategoryLinkGeneratedIndex;
|
package/lib/sidebars/utils.d.ts
CHANGED
|
@@ -27,6 +27,15 @@ export declare type SidebarsUtils = {
|
|
|
27
27
|
getDocNavigation: (unversionedId: string, versionedId: string) => SidebarNavigation;
|
|
28
28
|
getCategoryGeneratedIndexList: () => SidebarItemCategoryWithGeneratedIndex[];
|
|
29
29
|
getCategoryGeneratedIndexNavigation: (categoryGeneratedIndexPermalink: string) => SidebarNavigation;
|
|
30
|
+
getFirstLink: (sidebarId: string) => {
|
|
31
|
+
type: 'doc';
|
|
32
|
+
id: string;
|
|
33
|
+
label: string;
|
|
34
|
+
} | {
|
|
35
|
+
type: 'generated-index';
|
|
36
|
+
slug: string;
|
|
37
|
+
label: string;
|
|
38
|
+
} | undefined;
|
|
30
39
|
checkSidebarsDocIds: (validDocIds: string[], sidebarFilePath: string) => void;
|
|
31
40
|
};
|
|
32
41
|
export declare function createSidebarsUtils(sidebars: Sidebars): SidebarsUtils;
|
package/lib/sidebars/utils.js
CHANGED
|
@@ -173,6 +173,42 @@ Available document ids are:
|
|
|
173
173
|
- ${(0, lodash_1.uniq)(validDocIds).sort().join('\n- ')}`);
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
|
+
function getFirstLink(sidebar) {
|
|
177
|
+
var _a, _b, _c;
|
|
178
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
179
|
+
for (const item of sidebar) {
|
|
180
|
+
if (item.type === 'doc') {
|
|
181
|
+
return {
|
|
182
|
+
type: 'doc',
|
|
183
|
+
id: item.id,
|
|
184
|
+
label: (_a = item.label) !== null && _a !== void 0 ? _a : item.id,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
else if (item.type === 'category') {
|
|
188
|
+
if (((_b = item.link) === null || _b === void 0 ? void 0 : _b.type) === 'doc') {
|
|
189
|
+
return {
|
|
190
|
+
type: 'doc',
|
|
191
|
+
id: item.link.id,
|
|
192
|
+
label: item.label,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
else if (((_c = item.link) === null || _c === void 0 ? void 0 : _c.type) === 'generated-index') {
|
|
196
|
+
return {
|
|
197
|
+
type: 'generated-index',
|
|
198
|
+
slug: item.link.slug,
|
|
199
|
+
label: item.label,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
const firstSubItem = getFirstLink(item.items);
|
|
204
|
+
if (firstSubItem) {
|
|
205
|
+
return firstSubItem;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return undefined;
|
|
211
|
+
}
|
|
176
212
|
return {
|
|
177
213
|
sidebars,
|
|
178
214
|
getFirstDocIdOfFirstSidebar,
|
|
@@ -181,6 +217,7 @@ Available document ids are:
|
|
|
181
217
|
getCategoryGeneratedIndexList,
|
|
182
218
|
getCategoryGeneratedIndexNavigation,
|
|
183
219
|
checkSidebarsDocIds,
|
|
220
|
+
getFirstLink: (id) => getFirstLink(sidebars[id]),
|
|
184
221
|
};
|
|
185
222
|
}
|
|
186
223
|
exports.createSidebarsUtils = createSidebarsUtils;
|
|
@@ -50,6 +50,8 @@ const sidebarItemCategoryLinkSchema = utils_validation_1.Joi.object()
|
|
|
50
50
|
// permalink: Joi.string().optional(), // No, this one is not in the user config, only in the normalized version
|
|
51
51
|
title: utils_validation_1.Joi.string().optional(),
|
|
52
52
|
description: utils_validation_1.Joi.string().optional(),
|
|
53
|
+
image: utils_validation_1.Joi.string().optional(),
|
|
54
|
+
keywords: [utils_validation_1.Joi.string(), utils_validation_1.Joi.array().items(utils_validation_1.Joi.string())],
|
|
53
55
|
}),
|
|
54
56
|
},
|
|
55
57
|
{
|
package/lib/types.d.ts
CHANGED
|
@@ -144,6 +144,8 @@ export declare type CategoryGeneratedIndexMetadata = {
|
|
|
144
144
|
sidebar: string;
|
|
145
145
|
previous?: DocNavLink;
|
|
146
146
|
next?: DocNavLink;
|
|
147
|
+
image?: string;
|
|
148
|
+
keywords?: string | readonly string[];
|
|
147
149
|
};
|
|
148
150
|
export declare type SourceToPermalink = {
|
|
149
151
|
[source: string]: string;
|
|
@@ -178,6 +180,14 @@ export declare type GlobalVersion = {
|
|
|
178
180
|
path: string;
|
|
179
181
|
mainDocId: string;
|
|
180
182
|
docs: GlobalDoc[];
|
|
183
|
+
sidebars?: Record<string, GlobalSidebar>;
|
|
184
|
+
};
|
|
185
|
+
export declare type GlobalSidebarLink = {
|
|
186
|
+
label: string;
|
|
187
|
+
path: string;
|
|
188
|
+
};
|
|
189
|
+
export declare type GlobalSidebar = {
|
|
190
|
+
link?: GlobalSidebarLink;
|
|
181
191
|
};
|
|
182
192
|
export declare type GlobalPluginData = {
|
|
183
193
|
path: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-content-docs",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-4364",
|
|
4
4
|
"description": "Docs plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/plugin-content-docs.d.ts",
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/core": "0.0.0-
|
|
22
|
-
"@docusaurus/logger": "0.0.0-
|
|
23
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
24
|
-
"@docusaurus/utils": "0.0.0-
|
|
25
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
21
|
+
"@docusaurus/core": "0.0.0-4364",
|
|
22
|
+
"@docusaurus/logger": "0.0.0-4364",
|
|
23
|
+
"@docusaurus/mdx-loader": "0.0.0-4364",
|
|
24
|
+
"@docusaurus/utils": "0.0.0-4364",
|
|
25
|
+
"@docusaurus/utils-validation": "0.0.0-4364",
|
|
26
26
|
"combine-promises": "^1.1.0",
|
|
27
27
|
"escape-string-regexp": "^4.0.0",
|
|
28
28
|
"fs-extra": "^10.0.0",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"webpack": "^5.61.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
42
|
-
"@docusaurus/types": "0.0.0-
|
|
41
|
+
"@docusaurus/module-type-aliases": "0.0.0-4364",
|
|
42
|
+
"@docusaurus/types": "0.0.0-4364",
|
|
43
43
|
"@types/js-yaml": "^4.0.0",
|
|
44
44
|
"@types/picomatch": "^2.2.1",
|
|
45
45
|
"commander": "^5.1.0",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"engines": {
|
|
54
54
|
"node": ">=14"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "db9cb5ab444107d56734f4e8405721484197d0a9"
|
|
57
57
|
}
|
|
@@ -28,6 +28,8 @@ function getCategoryGeneratedIndexMetadata({
|
|
|
28
28
|
return {
|
|
29
29
|
title: category.link.title ?? category.label,
|
|
30
30
|
description: category.link.description,
|
|
31
|
+
image: category.link.image,
|
|
32
|
+
keywords: category.link.keywords,
|
|
31
33
|
slug: category.link.slug,
|
|
32
34
|
permalink: category.link.permalink,
|
|
33
35
|
sidebar: sidebarName,
|
package/src/globalData.ts
CHANGED
|
@@ -5,11 +5,16 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import {mapValues} from 'lodash';
|
|
9
|
+
import {normalizeUrl} from '@docusaurus/utils';
|
|
10
|
+
import type {Sidebars} from './sidebars/types';
|
|
11
|
+
import {createSidebarsUtils} from './sidebars/utils';
|
|
8
12
|
import type {
|
|
9
13
|
DocMetadata,
|
|
10
14
|
GlobalDoc,
|
|
11
15
|
LoadedVersion,
|
|
12
16
|
GlobalVersion,
|
|
17
|
+
GlobalSidebar,
|
|
13
18
|
} from './types';
|
|
14
19
|
|
|
15
20
|
export function toGlobalDataDoc(doc: DocMetadata): GlobalDoc {
|
|
@@ -20,6 +25,31 @@ export function toGlobalDataDoc(doc: DocMetadata): GlobalDoc {
|
|
|
20
25
|
};
|
|
21
26
|
}
|
|
22
27
|
|
|
28
|
+
export function toGlobalSidebars(
|
|
29
|
+
sidebars: Sidebars,
|
|
30
|
+
version: LoadedVersion,
|
|
31
|
+
): Record<string, GlobalSidebar> {
|
|
32
|
+
const {getFirstLink} = createSidebarsUtils(sidebars);
|
|
33
|
+
return mapValues(sidebars, (sidebar, sidebarId) => {
|
|
34
|
+
const firstLink = getFirstLink(sidebarId);
|
|
35
|
+
if (!firstLink) {
|
|
36
|
+
return {};
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
link: {
|
|
40
|
+
path:
|
|
41
|
+
firstLink.type === 'generated-index'
|
|
42
|
+
? normalizeUrl([version.versionPath, firstLink.slug])
|
|
43
|
+
: version.docs.find(
|
|
44
|
+
(doc) =>
|
|
45
|
+
doc.id === firstLink.id || doc.unversionedId === firstLink.id,
|
|
46
|
+
)!.permalink,
|
|
47
|
+
label: firstLink.label,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
23
53
|
export function toGlobalDataVersion(version: LoadedVersion): GlobalVersion {
|
|
24
54
|
return {
|
|
25
55
|
name: version.versionName,
|
|
@@ -28,5 +58,6 @@ export function toGlobalDataVersion(version: LoadedVersion): GlobalVersion {
|
|
|
28
58
|
path: version.versionPath,
|
|
29
59
|
mainDocId: version.mainDocId,
|
|
30
60
|
docs: version.docs.map(toGlobalDataDoc),
|
|
61
|
+
sidebars: toGlobalSidebars(version.sidebars, version),
|
|
31
62
|
};
|
|
32
63
|
}
|
|
@@ -11,9 +11,10 @@ declare module '@docusaurus/plugin-content-docs' {
|
|
|
11
11
|
export type VersionBanner = import('./types').VersionBanner;
|
|
12
12
|
type GlobalDataVersion = import('./types').GlobalVersion;
|
|
13
13
|
type GlobalDataDoc = import('./types').GlobalDoc;
|
|
14
|
+
type GlobalDataSidebar = import('./types').GlobalSidebar;
|
|
14
15
|
type VersionTag = import('./types').VersionTag;
|
|
15
16
|
|
|
16
|
-
export type {GlobalDataVersion, GlobalDataDoc};
|
|
17
|
+
export type {GlobalDataVersion, GlobalDataDoc, GlobalDataSidebar};
|
|
17
18
|
|
|
18
19
|
export type PropNavigationLink = {
|
|
19
20
|
readonly title: string;
|
|
@@ -42,6 +43,8 @@ declare module '@docusaurus/plugin-content-docs' {
|
|
|
42
43
|
export type PropCategoryGeneratedIndex = {
|
|
43
44
|
title: string;
|
|
44
45
|
description?: string;
|
|
46
|
+
image?: string;
|
|
47
|
+
keywords?: string | readonly string[];
|
|
45
48
|
slug: string;
|
|
46
49
|
permalink: string;
|
|
47
50
|
navigation: PropNavigation;
|
package/src/routes.ts
CHANGED
|
@@ -30,8 +30,17 @@ export async function createCategoryGeneratedIndexRoutes({
|
|
|
30
30
|
async function createCategoryGeneratedIndexRoute(
|
|
31
31
|
categoryGeneratedIndex: CategoryGeneratedIndexMetadata,
|
|
32
32
|
): Promise<RouteConfig> {
|
|
33
|
-
const {
|
|
34
|
-
|
|
33
|
+
const {
|
|
34
|
+
sidebar,
|
|
35
|
+
title,
|
|
36
|
+
description,
|
|
37
|
+
slug,
|
|
38
|
+
permalink,
|
|
39
|
+
previous,
|
|
40
|
+
next,
|
|
41
|
+
image,
|
|
42
|
+
keywords,
|
|
43
|
+
} = categoryGeneratedIndex;
|
|
35
44
|
|
|
36
45
|
const propFileName = slugs.slug(
|
|
37
46
|
`${version.versionPath}-${categoryGeneratedIndex.sidebar}-category-${categoryGeneratedIndex.title}`,
|
|
@@ -42,6 +51,8 @@ export async function createCategoryGeneratedIndexRoutes({
|
|
|
42
51
|
description,
|
|
43
52
|
slug,
|
|
44
53
|
permalink,
|
|
54
|
+
image,
|
|
55
|
+
keywords,
|
|
45
56
|
navigation: {
|
|
46
57
|
previous,
|
|
47
58
|
next,
|
package/src/sidebars/types.ts
CHANGED
|
@@ -52,6 +52,8 @@ export type SidebarItemCategoryLinkGeneratedIndexConfig = {
|
|
|
52
52
|
slug?: string;
|
|
53
53
|
title?: string;
|
|
54
54
|
description?: string;
|
|
55
|
+
image?: string;
|
|
56
|
+
keywords?: string | readonly string[];
|
|
55
57
|
};
|
|
56
58
|
export type SidebarItemCategoryLinkGeneratedIndex = {
|
|
57
59
|
type: 'generated-index';
|
|
@@ -59,6 +61,8 @@ export type SidebarItemCategoryLinkGeneratedIndex = {
|
|
|
59
61
|
permalink: string;
|
|
60
62
|
title?: string;
|
|
61
63
|
description?: string;
|
|
64
|
+
image?: string;
|
|
65
|
+
keywords?: string | readonly string[];
|
|
62
66
|
};
|
|
63
67
|
|
|
64
68
|
export type SidebarItemCategoryLinkConfig =
|
package/src/sidebars/utils.ts
CHANGED
|
@@ -136,6 +136,18 @@ export type SidebarsUtils = {
|
|
|
136
136
|
getCategoryGeneratedIndexNavigation: (
|
|
137
137
|
categoryGeneratedIndexPermalink: string,
|
|
138
138
|
) => SidebarNavigation;
|
|
139
|
+
getFirstLink: (sidebarId: string) =>
|
|
140
|
+
| {
|
|
141
|
+
type: 'doc';
|
|
142
|
+
id: string;
|
|
143
|
+
label: string;
|
|
144
|
+
}
|
|
145
|
+
| {
|
|
146
|
+
type: 'generated-index';
|
|
147
|
+
slug: string;
|
|
148
|
+
label: string;
|
|
149
|
+
}
|
|
150
|
+
| undefined;
|
|
139
151
|
|
|
140
152
|
checkSidebarsDocIds: (validDocIds: string[], sidebarFilePath: string) => void;
|
|
141
153
|
};
|
|
@@ -264,6 +276,50 @@ Available document ids are:
|
|
|
264
276
|
}
|
|
265
277
|
}
|
|
266
278
|
|
|
279
|
+
function getFirstLink(sidebar: Sidebar):
|
|
280
|
+
| {
|
|
281
|
+
type: 'doc';
|
|
282
|
+
id: string;
|
|
283
|
+
label: string;
|
|
284
|
+
}
|
|
285
|
+
| {
|
|
286
|
+
type: 'generated-index';
|
|
287
|
+
slug: string;
|
|
288
|
+
label: string;
|
|
289
|
+
}
|
|
290
|
+
| undefined {
|
|
291
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
292
|
+
for (const item of sidebar) {
|
|
293
|
+
if (item.type === 'doc') {
|
|
294
|
+
return {
|
|
295
|
+
type: 'doc',
|
|
296
|
+
id: item.id,
|
|
297
|
+
label: item.label ?? item.id,
|
|
298
|
+
};
|
|
299
|
+
} else if (item.type === 'category') {
|
|
300
|
+
if (item.link?.type === 'doc') {
|
|
301
|
+
return {
|
|
302
|
+
type: 'doc',
|
|
303
|
+
id: item.link.id,
|
|
304
|
+
label: item.label,
|
|
305
|
+
};
|
|
306
|
+
} else if (item.link?.type === 'generated-index') {
|
|
307
|
+
return {
|
|
308
|
+
type: 'generated-index',
|
|
309
|
+
slug: item.link.slug,
|
|
310
|
+
label: item.label,
|
|
311
|
+
};
|
|
312
|
+
} else {
|
|
313
|
+
const firstSubItem = getFirstLink(item.items);
|
|
314
|
+
if (firstSubItem) {
|
|
315
|
+
return firstSubItem;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return undefined;
|
|
321
|
+
}
|
|
322
|
+
|
|
267
323
|
return {
|
|
268
324
|
sidebars,
|
|
269
325
|
getFirstDocIdOfFirstSidebar,
|
|
@@ -272,6 +328,7 @@ Available document ids are:
|
|
|
272
328
|
getCategoryGeneratedIndexList,
|
|
273
329
|
getCategoryGeneratedIndexNavigation,
|
|
274
330
|
checkSidebarsDocIds,
|
|
331
|
+
getFirstLink: (id) => getFirstLink(sidebars[id]),
|
|
275
332
|
};
|
|
276
333
|
}
|
|
277
334
|
|
|
@@ -70,6 +70,8 @@ const sidebarItemCategoryLinkSchema = Joi.object<SidebarItemCategoryLink>()
|
|
|
70
70
|
// permalink: Joi.string().optional(), // No, this one is not in the user config, only in the normalized version
|
|
71
71
|
title: Joi.string().optional(),
|
|
72
72
|
description: Joi.string().optional(),
|
|
73
|
+
image: Joi.string().optional(),
|
|
74
|
+
keywords: [Joi.string(), Joi.array().items(Joi.string())],
|
|
73
75
|
}),
|
|
74
76
|
},
|
|
75
77
|
{
|
package/src/types.ts
CHANGED
|
@@ -174,6 +174,8 @@ export type CategoryGeneratedIndexMetadata = {
|
|
|
174
174
|
sidebar: string;
|
|
175
175
|
previous?: DocNavLink;
|
|
176
176
|
next?: DocNavLink;
|
|
177
|
+
image?: string;
|
|
178
|
+
keywords?: string | readonly string[];
|
|
177
179
|
};
|
|
178
180
|
|
|
179
181
|
export type SourceToPermalink = {
|
|
@@ -214,6 +216,17 @@ export type GlobalVersion = {
|
|
|
214
216
|
path: string;
|
|
215
217
|
mainDocId: string; // home doc (if docs homepage configured), or first doc
|
|
216
218
|
docs: GlobalDoc[];
|
|
219
|
+
sidebars?: Record<string, GlobalSidebar>;
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
export type GlobalSidebarLink = {
|
|
223
|
+
label: string;
|
|
224
|
+
path: string;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
export type GlobalSidebar = {
|
|
228
|
+
link?: GlobalSidebarLink;
|
|
229
|
+
// ... we may add other things here later
|
|
217
230
|
};
|
|
218
231
|
|
|
219
232
|
export type GlobalPluginData = {
|