@docusaurus/plugin-content-docs 0.0.0-4837 → 0.0.0-4840
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/cli.d.ts +3 -2
- package/lib/cli.js +34 -12
- package/lib/index.js +4 -9
- package/lib/props.d.ts +1 -1
- package/lib/props.js +3 -2
- package/lib/types.d.ts +3 -2
- package/lib/versions.d.ts +6 -0
- package/lib/versions.js +2 -1
- package/package.json +9 -9
- package/src/cli.ts +51 -21
- package/src/index.ts +4 -9
- package/src/plugin-content-docs.d.ts +8 -18
- package/src/props.ts +4 -3
- package/src/types.ts +3 -2
- package/src/versions.ts +2 -2
package/lib/cli.d.ts
CHANGED
|
@@ -4,5 +4,6 @@
|
|
|
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 {
|
|
8
|
-
|
|
7
|
+
import type { PluginOptions } from '@docusaurus/plugin-content-docs';
|
|
8
|
+
import type { LoadContext } from '@docusaurus/types';
|
|
9
|
+
export declare function cliDocsVersionCommand(version: string | null | undefined, { id: pluginId, path: docsPath, sidebarPath }: PluginOptions, { siteDir, i18n }: LoadContext): Promise<void>;
|
package/lib/cli.js
CHANGED
|
@@ -12,6 +12,7 @@ const versions_1 = require("./versions");
|
|
|
12
12
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
13
13
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
14
14
|
const sidebars_1 = require("./sidebars");
|
|
15
|
+
const constants_1 = require("./constants");
|
|
15
16
|
const utils_1 = require("@docusaurus/utils");
|
|
16
17
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
17
18
|
async function createVersionedSidebarFile({ siteDir, pluginId, sidebarPath, version, }) {
|
|
@@ -30,7 +31,7 @@ async function createVersionedSidebarFile({ siteDir, pluginId, sidebarPath, vers
|
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
// Tests depend on non-default export for mocking.
|
|
33
|
-
async function cliDocsVersionCommand(version,
|
|
34
|
+
async function cliDocsVersionCommand(version, { id: pluginId, path: docsPath, sidebarPath }, { siteDir, i18n }) {
|
|
34
35
|
// It wouldn't be very user-friendly to show a [default] log prefix,
|
|
35
36
|
// so we use [docs] instead of [default]
|
|
36
37
|
const pluginIdLogPrefix = pluginId === utils_1.DEFAULT_PLUGIN_ID ? '[docs]' : `[${pluginId}]`;
|
|
@@ -62,18 +63,39 @@ async function cliDocsVersionCommand(version, siteDir, pluginId, options) {
|
|
|
62
63
|
if (versions.includes(version)) {
|
|
63
64
|
throw new Error(`${pluginIdLogPrefix}: this version already exists! Use a version tag that does not already exist.`);
|
|
64
65
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const docsDir = path_1.default.resolve(siteDir, docsPath);
|
|
68
|
-
if ((await fs_extra_1.default.pathExists(docsDir)) &&
|
|
69
|
-
(await fs_extra_1.default.readdir(docsDir)).length > 0) {
|
|
70
|
-
const versionedDir = (0, versions_1.getVersionedDocsDirPath)(siteDir, pluginId);
|
|
71
|
-
const newVersionDir = path_1.default.join(versionedDir, `version-${version}`);
|
|
72
|
-
await fs_extra_1.default.copy(docsDir, newVersionDir);
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
throw new Error(`${pluginIdLogPrefix}: no docs found in ${docsDir}.`);
|
|
66
|
+
if (i18n.locales.length > 1) {
|
|
67
|
+
logger_1.default.info `Versioned docs will be created for the following locales: name=${i18n.locales}`;
|
|
76
68
|
}
|
|
69
|
+
await Promise.all(i18n.locales.map(async (locale) => {
|
|
70
|
+
// Copy docs files.
|
|
71
|
+
const docsDir = locale === i18n.defaultLocale
|
|
72
|
+
? path_1.default.resolve(siteDir, docsPath)
|
|
73
|
+
: (0, versions_1.getDocsDirPathLocalized)({
|
|
74
|
+
siteDir,
|
|
75
|
+
locale,
|
|
76
|
+
pluginId,
|
|
77
|
+
versionName: constants_1.CURRENT_VERSION_NAME,
|
|
78
|
+
});
|
|
79
|
+
if (!(await fs_extra_1.default.pathExists(docsDir)) ||
|
|
80
|
+
(await fs_extra_1.default.readdir(docsDir)).length === 0) {
|
|
81
|
+
if (locale === i18n.defaultLocale) {
|
|
82
|
+
throw new Error(logger_1.default.interpolate `${pluginIdLogPrefix}: no docs found in path=${docsDir}.`);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
logger_1.default.warn `${pluginIdLogPrefix}: no docs found in path=${docsDir}. Skipping.`;
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const newVersionDir = locale === i18n.defaultLocale
|
|
90
|
+
? path_1.default.join((0, versions_1.getVersionedDocsDirPath)(siteDir, pluginId), `version-${version}`)
|
|
91
|
+
: (0, versions_1.getDocsDirPathLocalized)({
|
|
92
|
+
siteDir,
|
|
93
|
+
locale,
|
|
94
|
+
pluginId,
|
|
95
|
+
versionName: version,
|
|
96
|
+
});
|
|
97
|
+
await fs_extra_1.default.copy(docsDir, newVersionDir);
|
|
98
|
+
}));
|
|
77
99
|
await createVersionedSidebarFile({
|
|
78
100
|
siteDir,
|
|
79
101
|
pluginId,
|
package/lib/index.js
CHANGED
|
@@ -27,7 +27,7 @@ const categoryGeneratedIndex_1 = require("./categoryGeneratedIndex");
|
|
|
27
27
|
async function pluginContentDocs(context, options) {
|
|
28
28
|
const { siteDir, generatedFilesDir, baseUrl, siteConfig } = context;
|
|
29
29
|
const versionsMetadata = await (0, versions_1.readVersionsMetadata)({ context, options });
|
|
30
|
-
const pluginId = options.id
|
|
30
|
+
const pluginId = options.id;
|
|
31
31
|
const pluginDataDirRoot = path_1.default.join(generatedFilesDir, 'docusaurus-plugin-content-docs');
|
|
32
32
|
const dataDir = path_1.default.join(pluginDataDirRoot, pluginId);
|
|
33
33
|
const aliasedSource = (source) => `~docs/${(0, utils_1.posixPath)(path_1.default.relative(pluginDataDirRoot, source))}`;
|
|
@@ -48,12 +48,7 @@ async function pluginContentDocs(context, options) {
|
|
|
48
48
|
.arguments('<version>')
|
|
49
49
|
.description(commandDescription)
|
|
50
50
|
.action((version) => {
|
|
51
|
-
(0, cli_1.cliDocsVersionCommand)(version,
|
|
52
|
-
path: options.path,
|
|
53
|
-
sidebarPath: options.sidebarPath,
|
|
54
|
-
sidebarCollapsed: options.sidebarCollapsed,
|
|
55
|
-
sidebarCollapsible: options.sidebarCollapsible,
|
|
56
|
-
});
|
|
51
|
+
(0, cli_1.cliDocsVersionCommand)(version, options, context);
|
|
57
52
|
});
|
|
58
53
|
},
|
|
59
54
|
getTranslationFiles({ content }) {
|
|
@@ -138,12 +133,12 @@ async function pluginContentDocs(context, options) {
|
|
|
138
133
|
// TODO tags should be a sub route of the version route
|
|
139
134
|
async function createTagsListPage() {
|
|
140
135
|
const tagsProp = Object.values(versionTags).map((tagValue) => ({
|
|
141
|
-
|
|
136
|
+
label: tagValue.label,
|
|
142
137
|
permalink: tagValue.permalink,
|
|
143
138
|
count: tagValue.docIds.length,
|
|
144
139
|
}));
|
|
145
140
|
// Only create /tags page if there are tags.
|
|
146
|
-
if (
|
|
141
|
+
if (tagsProp.length > 0) {
|
|
147
142
|
const tagsPropPath = await createData(`${(0, utils_1.docuHash)(`tags-list-${version.versionName}-prop`)}.json`, JSON.stringify(tagsProp, null, 2));
|
|
148
143
|
addRoute({
|
|
149
144
|
path: version.tagsPath,
|
package/lib/props.d.ts
CHANGED
|
@@ -11,5 +11,5 @@ export declare function toVersionMetadataProp(pluginId: string, loadedVersion: L
|
|
|
11
11
|
export declare function toTagDocListProp({ allTagsPath, tag, docs, }: {
|
|
12
12
|
allTagsPath: string;
|
|
13
13
|
tag: VersionTag;
|
|
14
|
-
docs:
|
|
14
|
+
docs: DocMetadata[];
|
|
15
15
|
}): PropTagDocList;
|
package/lib/props.js
CHANGED
|
@@ -104,10 +104,11 @@ function toTagDocListProp({ allTagsPath, tag, docs, }) {
|
|
|
104
104
|
}));
|
|
105
105
|
}
|
|
106
106
|
return {
|
|
107
|
-
|
|
107
|
+
label: tag.label,
|
|
108
108
|
permalink: tag.permalink,
|
|
109
|
-
docs: toDocListProp(),
|
|
110
109
|
allTagsPath,
|
|
110
|
+
count: tag.docIds.length,
|
|
111
|
+
items: toDocListProp(),
|
|
111
112
|
};
|
|
112
113
|
}
|
|
113
114
|
exports.toTagDocListProp = toTagDocListProp;
|
package/lib/types.d.ts
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { Sidebars } from './sidebars/types';
|
|
8
|
-
import type { BrokenMarkdownLink
|
|
8
|
+
import type { BrokenMarkdownLink } from '@docusaurus/utils';
|
|
9
9
|
import type { VersionMetadata, LastUpdateData, DocMetadata, CategoryGeneratedIndexMetadata } from '@docusaurus/plugin-content-docs';
|
|
10
|
+
import type { Tag } from '@docusaurus/types';
|
|
10
11
|
export declare type DocFile = {
|
|
11
12
|
contentPath: string;
|
|
12
13
|
filePath: string;
|
|
@@ -22,7 +23,7 @@ export declare type VersionTag = Tag & {
|
|
|
22
23
|
docIds: string[];
|
|
23
24
|
};
|
|
24
25
|
export declare type VersionTags = {
|
|
25
|
-
[
|
|
26
|
+
[permalink: string]: VersionTag;
|
|
26
27
|
};
|
|
27
28
|
export declare type LoadedVersion = VersionMetadata & {
|
|
28
29
|
mainDocId: string;
|
package/lib/versions.d.ts
CHANGED
|
@@ -11,6 +11,12 @@ export declare function getVersionedSidebarsDirPath(siteDir: string, pluginId: s
|
|
|
11
11
|
export declare function getVersionsFilePath(siteDir: string, pluginId: string): string;
|
|
12
12
|
export declare function readVersionsFile(siteDir: string, pluginId: string): Promise<string[] | null>;
|
|
13
13
|
export declare function readVersionNames(siteDir: string, options: Pick<PluginOptions, 'id' | 'disableVersioning' | 'includeCurrentVersion'>): Promise<string[]>;
|
|
14
|
+
export declare function getDocsDirPathLocalized({ siteDir, locale, pluginId, versionName, }: {
|
|
15
|
+
siteDir: string;
|
|
16
|
+
locale: string;
|
|
17
|
+
pluginId: string;
|
|
18
|
+
versionName: string;
|
|
19
|
+
}): string;
|
|
14
20
|
export declare function getDefaultVersionBanner({ versionName, versionNames, lastVersionName, }: {
|
|
15
21
|
versionName: string;
|
|
16
22
|
versionNames: string[];
|
package/lib/versions.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.readVersionsMetadata = exports.filterVersions = exports.getVersionBadge = exports.getVersionBanner = exports.getDefaultVersionBanner = exports.readVersionNames = exports.readVersionsFile = exports.getVersionsFilePath = exports.getVersionedSidebarsDirPath = exports.getVersionedDocsDirPath = void 0;
|
|
9
|
+
exports.readVersionsMetadata = exports.filterVersions = exports.getVersionBadge = exports.getVersionBanner = exports.getDefaultVersionBanner = exports.getDocsDirPathLocalized = exports.readVersionNames = exports.readVersionsFile = exports.getVersionsFilePath = exports.getVersionedSidebarsDirPath = exports.getVersionedDocsDirPath = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
12
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
@@ -89,6 +89,7 @@ function getDocsDirPathLocalized({ siteDir, locale, pluginId, versionName, }) {
|
|
|
89
89
|
],
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
|
+
exports.getDocsDirPathLocalized = getDocsDirPathLocalized;
|
|
92
93
|
function getVersionMetadataPaths({ versionName, context, options, }) {
|
|
93
94
|
const isCurrentVersion = versionName === constants_1.CURRENT_VERSION_NAME;
|
|
94
95
|
const contentPathLocalized = getDocsDirPathLocalized({
|
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-4840",
|
|
4
4
|
"description": "Docs plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@docusaurus/core": "0.0.0-
|
|
27
|
-
"@docusaurus/logger": "0.0.0-
|
|
28
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
29
|
-
"@docusaurus/utils": "0.0.0-
|
|
30
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
26
|
+
"@docusaurus/core": "0.0.0-4840",
|
|
27
|
+
"@docusaurus/logger": "0.0.0-4840",
|
|
28
|
+
"@docusaurus/mdx-loader": "0.0.0-4840",
|
|
29
|
+
"@docusaurus/utils": "0.0.0-4840",
|
|
30
|
+
"@docusaurus/utils-validation": "0.0.0-4840",
|
|
31
31
|
"combine-promises": "^1.1.0",
|
|
32
32
|
"fs-extra": "^10.0.1",
|
|
33
33
|
"import-fresh": "^3.3.0",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"webpack": "^5.70.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
43
|
-
"@docusaurus/types": "0.0.0-
|
|
42
|
+
"@docusaurus/module-type-aliases": "0.0.0-4840",
|
|
43
|
+
"@docusaurus/types": "0.0.0-4840",
|
|
44
44
|
"@types/js-yaml": "^4.0.5",
|
|
45
45
|
"@types/picomatch": "^2.3.0",
|
|
46
46
|
"commander": "^5.1.0",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"engines": {
|
|
57
57
|
"node": ">=14"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "31e83775c132dee13950e08b0cb9c936c13f80d5"
|
|
60
60
|
}
|
package/src/cli.ts
CHANGED
|
@@ -9,16 +9,16 @@ import {
|
|
|
9
9
|
getVersionsFilePath,
|
|
10
10
|
getVersionedDocsDirPath,
|
|
11
11
|
getVersionedSidebarsDirPath,
|
|
12
|
+
getDocsDirPathLocalized,
|
|
12
13
|
} from './versions';
|
|
13
14
|
import fs from 'fs-extra';
|
|
14
15
|
import path from 'path';
|
|
15
|
-
import type {
|
|
16
|
-
PathOptions,
|
|
17
|
-
SidebarOptions,
|
|
18
|
-
} from '@docusaurus/plugin-content-docs';
|
|
16
|
+
import type {PluginOptions} from '@docusaurus/plugin-content-docs';
|
|
19
17
|
import {loadSidebarsFileUnsafe, resolveSidebarPathOption} from './sidebars';
|
|
18
|
+
import {CURRENT_VERSION_NAME} from './constants';
|
|
20
19
|
import {DEFAULT_PLUGIN_ID} from '@docusaurus/utils';
|
|
21
20
|
import logger from '@docusaurus/logger';
|
|
21
|
+
import type {LoadContext} from '@docusaurus/types';
|
|
22
22
|
|
|
23
23
|
async function createVersionedSidebarFile({
|
|
24
24
|
siteDir,
|
|
@@ -58,9 +58,8 @@ async function createVersionedSidebarFile({
|
|
|
58
58
|
// Tests depend on non-default export for mocking.
|
|
59
59
|
export async function cliDocsVersionCommand(
|
|
60
60
|
version: string | null | undefined,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
options: PathOptions & SidebarOptions,
|
|
61
|
+
{id: pluginId, path: docsPath, sidebarPath}: PluginOptions,
|
|
62
|
+
{siteDir, i18n}: LoadContext,
|
|
64
63
|
): Promise<void> {
|
|
65
64
|
// It wouldn't be very user-friendly to show a [default] log prefix,
|
|
66
65
|
// so we use [docs] instead of [default]
|
|
@@ -114,22 +113,53 @@ export async function cliDocsVersionCommand(
|
|
|
114
113
|
);
|
|
115
114
|
}
|
|
116
115
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
// Copy docs files.
|
|
120
|
-
const docsDir = path.resolve(siteDir, docsPath);
|
|
121
|
-
|
|
122
|
-
if (
|
|
123
|
-
(await fs.pathExists(docsDir)) &&
|
|
124
|
-
(await fs.readdir(docsDir)).length > 0
|
|
125
|
-
) {
|
|
126
|
-
const versionedDir = getVersionedDocsDirPath(siteDir, pluginId);
|
|
127
|
-
const newVersionDir = path.join(versionedDir, `version-${version}`);
|
|
128
|
-
await fs.copy(docsDir, newVersionDir);
|
|
129
|
-
} else {
|
|
130
|
-
throw new Error(`${pluginIdLogPrefix}: no docs found in ${docsDir}.`);
|
|
116
|
+
if (i18n.locales.length > 1) {
|
|
117
|
+
logger.info`Versioned docs will be created for the following locales: name=${i18n.locales}`;
|
|
131
118
|
}
|
|
132
119
|
|
|
120
|
+
await Promise.all(
|
|
121
|
+
i18n.locales.map(async (locale) => {
|
|
122
|
+
// Copy docs files.
|
|
123
|
+
const docsDir =
|
|
124
|
+
locale === i18n.defaultLocale
|
|
125
|
+
? path.resolve(siteDir, docsPath)
|
|
126
|
+
: getDocsDirPathLocalized({
|
|
127
|
+
siteDir,
|
|
128
|
+
locale,
|
|
129
|
+
pluginId,
|
|
130
|
+
versionName: CURRENT_VERSION_NAME,
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
if (
|
|
134
|
+
!(await fs.pathExists(docsDir)) ||
|
|
135
|
+
(await fs.readdir(docsDir)).length === 0
|
|
136
|
+
) {
|
|
137
|
+
if (locale === i18n.defaultLocale) {
|
|
138
|
+
throw new Error(
|
|
139
|
+
logger.interpolate`${pluginIdLogPrefix}: no docs found in path=${docsDir}.`,
|
|
140
|
+
);
|
|
141
|
+
} else {
|
|
142
|
+
logger.warn`${pluginIdLogPrefix}: no docs found in path=${docsDir}. Skipping.`;
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const newVersionDir =
|
|
148
|
+
locale === i18n.defaultLocale
|
|
149
|
+
? path.join(
|
|
150
|
+
getVersionedDocsDirPath(siteDir, pluginId),
|
|
151
|
+
`version-${version}`,
|
|
152
|
+
)
|
|
153
|
+
: getDocsDirPathLocalized({
|
|
154
|
+
siteDir,
|
|
155
|
+
locale,
|
|
156
|
+
pluginId,
|
|
157
|
+
versionName: version,
|
|
158
|
+
});
|
|
159
|
+
await fs.copy(docsDir, newVersionDir);
|
|
160
|
+
}),
|
|
161
|
+
);
|
|
162
|
+
|
|
133
163
|
await createVersionedSidebarFile({
|
|
134
164
|
siteDir,
|
|
135
165
|
pluginId,
|
package/src/index.ts
CHANGED
|
@@ -67,7 +67,7 @@ export default async function pluginContentDocs(
|
|
|
67
67
|
|
|
68
68
|
const versionsMetadata = await readVersionsMetadata({context, options});
|
|
69
69
|
|
|
70
|
-
const pluginId = options.id
|
|
70
|
+
const pluginId = options.id;
|
|
71
71
|
|
|
72
72
|
const pluginDataDirRoot = path.join(
|
|
73
73
|
generatedFilesDir,
|
|
@@ -97,12 +97,7 @@ export default async function pluginContentDocs(
|
|
|
97
97
|
.arguments('<version>')
|
|
98
98
|
.description(commandDescription)
|
|
99
99
|
.action((version) => {
|
|
100
|
-
cliDocsVersionCommand(version,
|
|
101
|
-
path: options.path,
|
|
102
|
-
sidebarPath: options.sidebarPath,
|
|
103
|
-
sidebarCollapsed: options.sidebarCollapsed,
|
|
104
|
-
sidebarCollapsible: options.sidebarCollapsible,
|
|
105
|
-
});
|
|
100
|
+
cliDocsVersionCommand(version, options, context);
|
|
106
101
|
});
|
|
107
102
|
},
|
|
108
103
|
|
|
@@ -228,13 +223,13 @@ export default async function pluginContentDocs(
|
|
|
228
223
|
const tagsProp: PropTagsListPage['tags'] = Object.values(
|
|
229
224
|
versionTags,
|
|
230
225
|
).map((tagValue) => ({
|
|
231
|
-
|
|
226
|
+
label: tagValue.label,
|
|
232
227
|
permalink: tagValue.permalink,
|
|
233
228
|
count: tagValue.docIds.length,
|
|
234
229
|
}));
|
|
235
230
|
|
|
236
231
|
// Only create /tags page if there are tags.
|
|
237
|
-
if (
|
|
232
|
+
if (tagsProp.length > 0) {
|
|
238
233
|
const tagsPropPath = await createData(
|
|
239
234
|
`${docuHash(`tags-list-${version.versionName}-prop`)}.json`,
|
|
240
235
|
JSON.stringify(tagsProp, null, 2),
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
declare module '@docusaurus/plugin-content-docs' {
|
|
9
9
|
import type {MDXOptions} from '@docusaurus/mdx-loader';
|
|
10
|
-
import type {ContentPaths,
|
|
10
|
+
import type {ContentPaths, FrontMatterTag} from '@docusaurus/utils';
|
|
11
|
+
import type {TagsListItem, TagModule, Tag} from '@docusaurus/types';
|
|
11
12
|
import type {Required} from 'utility-types';
|
|
12
13
|
|
|
13
14
|
export type Assets = {
|
|
@@ -483,25 +484,14 @@ declare module '@docusaurus/plugin-content-docs' {
|
|
|
483
484
|
export type PropSidebar = import('./sidebars/types').PropSidebar;
|
|
484
485
|
export type PropSidebars = import('./sidebars/types').PropSidebars;
|
|
485
486
|
|
|
486
|
-
export type PropTagDocListDoc =
|
|
487
|
-
|
|
488
|
-
title
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
};
|
|
492
|
-
export type PropTagDocList = {
|
|
493
|
-
allTagsPath: string;
|
|
494
|
-
name: string; // normalized name/label of the tag
|
|
495
|
-
permalink: string; // pathname of the tag
|
|
496
|
-
docs: PropTagDocListDoc[];
|
|
497
|
-
};
|
|
487
|
+
export type PropTagDocListDoc = Pick<
|
|
488
|
+
DocMetadata,
|
|
489
|
+
'id' | 'title' | 'description' | 'permalink'
|
|
490
|
+
>;
|
|
491
|
+
export type PropTagDocList = TagModule & {items: PropTagDocListDoc[]};
|
|
498
492
|
|
|
499
493
|
export type PropTagsListPage = {
|
|
500
|
-
tags:
|
|
501
|
-
name: string;
|
|
502
|
-
permalink: string;
|
|
503
|
-
count: number;
|
|
504
|
-
}[];
|
|
494
|
+
tags: TagsListItem[];
|
|
505
495
|
};
|
|
506
496
|
}
|
|
507
497
|
|
package/src/props.ts
CHANGED
|
@@ -137,7 +137,7 @@ export function toTagDocListProp({
|
|
|
137
137
|
}: {
|
|
138
138
|
allTagsPath: string;
|
|
139
139
|
tag: VersionTag;
|
|
140
|
-
docs:
|
|
140
|
+
docs: DocMetadata[];
|
|
141
141
|
}): PropTagDocList {
|
|
142
142
|
function toDocListProp(): PropTagDocListDoc[] {
|
|
143
143
|
const list = _.compact(
|
|
@@ -154,9 +154,10 @@ export function toTagDocListProp({
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
return {
|
|
157
|
-
|
|
157
|
+
label: tag.label,
|
|
158
158
|
permalink: tag.permalink,
|
|
159
|
-
docs: toDocListProp(),
|
|
160
159
|
allTagsPath,
|
|
160
|
+
count: tag.docIds.length,
|
|
161
|
+
items: toDocListProp(),
|
|
161
162
|
};
|
|
162
163
|
}
|
package/src/types.ts
CHANGED
|
@@ -8,13 +8,14 @@
|
|
|
8
8
|
/// <reference types="@docusaurus/module-type-aliases" />
|
|
9
9
|
|
|
10
10
|
import type {Sidebars} from './sidebars/types';
|
|
11
|
-
import type {BrokenMarkdownLink
|
|
11
|
+
import type {BrokenMarkdownLink} from '@docusaurus/utils';
|
|
12
12
|
import type {
|
|
13
13
|
VersionMetadata,
|
|
14
14
|
LastUpdateData,
|
|
15
15
|
DocMetadata,
|
|
16
16
|
CategoryGeneratedIndexMetadata,
|
|
17
17
|
} from '@docusaurus/plugin-content-docs';
|
|
18
|
+
import type {Tag} from '@docusaurus/types';
|
|
18
19
|
|
|
19
20
|
export type DocFile = {
|
|
20
21
|
contentPath: string; // /!\ may be localized
|
|
@@ -33,7 +34,7 @@ export type VersionTag = Tag & {
|
|
|
33
34
|
docIds: string[];
|
|
34
35
|
};
|
|
35
36
|
export type VersionTags = {
|
|
36
|
-
[
|
|
37
|
+
[permalink: string]: VersionTag;
|
|
37
38
|
};
|
|
38
39
|
|
|
39
40
|
export type LoadedVersion = VersionMetadata & {
|
package/src/versions.ts
CHANGED
|
@@ -133,7 +133,7 @@ export async function readVersionNames(
|
|
|
133
133
|
return versions;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
function getDocsDirPathLocalized({
|
|
136
|
+
export function getDocsDirPathLocalized({
|
|
137
137
|
siteDir,
|
|
138
138
|
locale,
|
|
139
139
|
pluginId,
|
|
@@ -143,7 +143,7 @@ function getDocsDirPathLocalized({
|
|
|
143
143
|
locale: string;
|
|
144
144
|
pluginId: string;
|
|
145
145
|
versionName: string;
|
|
146
|
-
}) {
|
|
146
|
+
}): string {
|
|
147
147
|
return getPluginI18nPath({
|
|
148
148
|
siteDir,
|
|
149
149
|
locale,
|