@docusaurus/plugin-content-docs 0.0.0-4788 → 0.0.0-4792
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.d.ts +1 -1
- package/lib/categoryGeneratedIndex.js +4 -2
- package/lib/docs.d.ts +3 -3
- package/lib/docs.js +4 -5
- package/lib/frontMatter.d.ts +1 -1
- package/lib/globalData.js +2 -2
- package/lib/index.js +3 -3
- package/lib/markdown/linkify.js +1 -2
- package/lib/props.d.ts +2 -2
- package/lib/props.js +5 -5
- package/lib/routes.d.ts +2 -1
- package/lib/routes.js +4 -16
- package/lib/sidebars/normalization.js +1 -1
- package/lib/sidebars/postProcessor.js +1 -1
- package/lib/sidebars/types.d.ts +14 -11
- package/lib/sidebars/utils.d.ts +3 -3
- package/lib/slug.d.ts +1 -2
- package/lib/tags.d.ts +2 -1
- package/lib/tags.js +1 -1
- package/lib/translations.js +2 -2
- package/lib/types.d.ts +4 -87
- package/lib/versions.d.ts +1 -3
- package/lib/versions.js +21 -32
- package/package.json +9 -9
- package/src/categoryGeneratedIndex.ts +8 -3
- package/src/docs.ts +13 -17
- package/src/frontMatter.ts +1 -1
- package/src/globalData.ts +4 -4
- package/src/index.ts +8 -8
- package/src/markdown/linkify.ts +2 -3
- package/src/plugin-content-docs.d.ts +377 -66
- package/src/props.ts +8 -7
- package/src/routes.ts +6 -30
- package/src/sidebars/normalization.ts +1 -1
- package/src/sidebars/postProcessor.ts +1 -1
- package/src/sidebars/processor.ts +4 -1
- package/src/sidebars/types.ts +15 -11
- package/src/sidebars/utils.ts +6 -3
- package/src/slug.ts +4 -2
- package/src/tags.ts +3 -2
- package/src/translations.ts +2 -3
- package/src/types.ts +9 -96
- package/src/versions.ts +28 -41
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-4792",
|
|
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-4792",
|
|
27
|
+
"@docusaurus/logger": "0.0.0-4792",
|
|
28
|
+
"@docusaurus/mdx-loader": "0.0.0-4792",
|
|
29
|
+
"@docusaurus/utils": "0.0.0-4792",
|
|
30
|
+
"@docusaurus/utils-validation": "0.0.0-4792",
|
|
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.0"
|
|
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-4792",
|
|
43
|
+
"@docusaurus/types": "0.0.0-4792",
|
|
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": "38eb1dcf25728a582b37f71e41ad5d21cc17db1f"
|
|
60
60
|
}
|
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type {
|
|
8
|
+
import type {
|
|
9
|
+
CategoryGeneratedIndexMetadata,
|
|
10
|
+
DocMetadataBase,
|
|
11
|
+
} from '@docusaurus/plugin-content-docs';
|
|
9
12
|
import type {SidebarItemCategoryWithGeneratedIndex} from './sidebars/types';
|
|
10
13
|
import {type SidebarsUtils, toNavigationLink} from './sidebars/utils';
|
|
11
14
|
import {createDocsByIdIndex} from './docs';
|
|
@@ -29,8 +32,10 @@ function getCategoryGeneratedIndexMetadata({
|
|
|
29
32
|
slug: category.link.slug,
|
|
30
33
|
permalink: category.link.permalink,
|
|
31
34
|
sidebar: sidebarName!,
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
navigation: {
|
|
36
|
+
previous: toNavigationLink(previous, docsById),
|
|
37
|
+
next: toNavigationLink(next, docsById),
|
|
38
|
+
},
|
|
34
39
|
};
|
|
35
40
|
}
|
|
36
41
|
|
package/src/docs.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
aliasedSitePath,
|
|
13
13
|
getEditUrl,
|
|
14
14
|
getFolderContainingFile,
|
|
15
|
+
getContentPathList,
|
|
15
16
|
normalizeUrl,
|
|
16
17
|
parseMarkdownString,
|
|
17
18
|
posixPath,
|
|
@@ -21,18 +22,9 @@ import {
|
|
|
21
22
|
import type {LoadContext} from '@docusaurus/types';
|
|
22
23
|
|
|
23
24
|
import {getFileLastUpdate} from './lastUpdate';
|
|
24
|
-
import type {
|
|
25
|
-
DocFile,
|
|
26
|
-
DocMetadataBase,
|
|
27
|
-
DocMetadata,
|
|
28
|
-
DocNavLink,
|
|
29
|
-
LastUpdateData,
|
|
30
|
-
VersionMetadata,
|
|
31
|
-
LoadedVersion,
|
|
32
|
-
} from './types';
|
|
25
|
+
import type {DocFile, LoadedVersion} from './types';
|
|
33
26
|
import getSlug from './slug';
|
|
34
27
|
import {CURRENT_VERSION_NAME} from './constants';
|
|
35
|
-
import {getDocsDirPaths} from './versions';
|
|
36
28
|
import {stripPathNumberPrefixes} from './numberPrefix';
|
|
37
29
|
import {validateDocFrontMatter} from './frontMatter';
|
|
38
30
|
import type {SidebarsUtils} from './sidebars/utils';
|
|
@@ -41,7 +33,11 @@ import type {
|
|
|
41
33
|
MetadataOptions,
|
|
42
34
|
PluginOptions,
|
|
43
35
|
CategoryIndexMatcher,
|
|
44
|
-
|
|
36
|
+
DocMetadataBase,
|
|
37
|
+
DocMetadata,
|
|
38
|
+
PropNavigationLink,
|
|
39
|
+
LastUpdateData,
|
|
40
|
+
VersionMetadata,
|
|
45
41
|
} from '@docusaurus/plugin-content-docs';
|
|
46
42
|
|
|
47
43
|
type LastUpdateOptions = Pick<
|
|
@@ -85,7 +81,7 @@ export async function readDocFile(
|
|
|
85
81
|
options: LastUpdateOptions,
|
|
86
82
|
): Promise<DocFile> {
|
|
87
83
|
const contentPath = await getFolderContainingFile(
|
|
88
|
-
|
|
84
|
+
getContentPathList(versionMetadata),
|
|
89
85
|
source,
|
|
90
86
|
);
|
|
91
87
|
|
|
@@ -213,7 +209,7 @@ function doProcessDocMetadata({
|
|
|
213
209
|
|
|
214
210
|
const description: string = frontMatter.description ?? excerpt ?? '';
|
|
215
211
|
|
|
216
|
-
const permalink = normalizeUrl([versionMetadata.
|
|
212
|
+
const permalink = normalizeUrl([versionMetadata.path, docSlug]);
|
|
217
213
|
|
|
218
214
|
function getDocEditUrl() {
|
|
219
215
|
const relativeFilePath = path.relative(contentPath, filePath);
|
|
@@ -232,8 +228,8 @@ function doProcessDocMetadata({
|
|
|
232
228
|
const isLocalized = contentPath === versionMetadata.contentPathLocalized;
|
|
233
229
|
const baseVersionEditUrl =
|
|
234
230
|
isLocalized && options.editLocalizedFiles
|
|
235
|
-
? versionMetadata.
|
|
236
|
-
: versionMetadata.
|
|
231
|
+
? versionMetadata.editUrlLocalized
|
|
232
|
+
: versionMetadata.editUrl;
|
|
237
233
|
return getEditUrl(relativeFilePath, baseVersionEditUrl);
|
|
238
234
|
}
|
|
239
235
|
return undefined;
|
|
@@ -304,7 +300,7 @@ export function addDocNavigation(
|
|
|
304
300
|
const toNavigationLinkByDocId = (
|
|
305
301
|
docId: string | null | undefined,
|
|
306
302
|
type: 'prev' | 'next',
|
|
307
|
-
):
|
|
303
|
+
): PropNavigationLink | undefined => {
|
|
308
304
|
if (!docId) {
|
|
309
305
|
return undefined;
|
|
310
306
|
}
|
|
@@ -401,7 +397,7 @@ export function toCategoryIndexMatcherParam({
|
|
|
401
397
|
}: Pick<
|
|
402
398
|
DocMetadataBase,
|
|
403
399
|
'source' | 'sourceDirName'
|
|
404
|
-
>):
|
|
400
|
+
>): Parameters<CategoryIndexMatcher>[0] {
|
|
405
401
|
// source + sourceDirName are always posix-style
|
|
406
402
|
return {
|
|
407
403
|
fileName: path.posix.parse(source).name,
|
package/src/frontMatter.ts
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
FrontMatterTOCHeadingLevels,
|
|
13
13
|
validateFrontMatter,
|
|
14
14
|
} from '@docusaurus/utils-validation';
|
|
15
|
-
import type {DocFrontMatter} from '
|
|
15
|
+
import type {DocFrontMatter} from '@docusaurus/plugin-content-docs';
|
|
16
16
|
|
|
17
17
|
// NOTE: we don't add any default value on purpose here
|
|
18
18
|
// We don't want default values to magically appear in doc metadata and props
|
package/src/globalData.ts
CHANGED
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
import _ from 'lodash';
|
|
9
9
|
import type {Sidebars} from './sidebars/types';
|
|
10
10
|
import {createSidebarsUtils} from './sidebars/utils';
|
|
11
|
+
import type {LoadedVersion} from './types';
|
|
11
12
|
import type {
|
|
12
13
|
CategoryGeneratedIndexMetadata,
|
|
13
14
|
DocMetadata,
|
|
14
|
-
|
|
15
|
-
} from './types';
|
|
15
|
+
} from '@docusaurus/plugin-content-docs';
|
|
16
16
|
import type {
|
|
17
17
|
GlobalVersion,
|
|
18
18
|
GlobalSidebar,
|
|
@@ -65,9 +65,9 @@ function toGlobalSidebars(
|
|
|
65
65
|
export function toGlobalDataVersion(version: LoadedVersion): GlobalVersion {
|
|
66
66
|
return {
|
|
67
67
|
name: version.versionName,
|
|
68
|
-
label: version.
|
|
68
|
+
label: version.label,
|
|
69
69
|
isLast: version.isLast,
|
|
70
|
-
path: version.
|
|
70
|
+
path: version.path,
|
|
71
71
|
mainDocId: version.mainDocId,
|
|
72
72
|
docs: version.docs
|
|
73
73
|
.map(toGlobalDataDoc)
|
package/src/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
normalizeUrl,
|
|
12
12
|
docuHash,
|
|
13
13
|
aliasedSitePath,
|
|
14
|
+
getContentPathList,
|
|
14
15
|
reportMessage,
|
|
15
16
|
posixPath,
|
|
16
17
|
addTrailingPathSeparator,
|
|
@@ -27,18 +28,14 @@ import {
|
|
|
27
28
|
addDocNavigation,
|
|
28
29
|
getMainDocId,
|
|
29
30
|
} from './docs';
|
|
30
|
-
import {
|
|
31
|
-
|
|
31
|
+
import {readVersionsMetadata} from './versions';
|
|
32
32
|
import type {
|
|
33
33
|
LoadedContent,
|
|
34
34
|
SourceToPermalink,
|
|
35
|
-
DocMetadataBase,
|
|
36
|
-
VersionMetadata,
|
|
37
35
|
LoadedVersion,
|
|
38
36
|
DocFile,
|
|
39
37
|
DocsMarkdownOption,
|
|
40
38
|
VersionTag,
|
|
41
|
-
DocFrontMatter,
|
|
42
39
|
} from './types';
|
|
43
40
|
import type {RuleSetRule} from 'webpack';
|
|
44
41
|
import {cliDocsVersionCommand} from './cli';
|
|
@@ -55,6 +52,9 @@ import {createVersionRoutes} from './routes';
|
|
|
55
52
|
import type {
|
|
56
53
|
PropTagsListPage,
|
|
57
54
|
PluginOptions,
|
|
55
|
+
DocMetadataBase,
|
|
56
|
+
VersionMetadata,
|
|
57
|
+
DocFrontMatter,
|
|
58
58
|
} from '@docusaurus/plugin-content-docs';
|
|
59
59
|
import {createSidebarsUtils} from './sidebars/utils';
|
|
60
60
|
import {getCategoryGeneratedIndexMetadataList} from './categoryGeneratedIndex';
|
|
@@ -114,7 +114,7 @@ export default async function pluginContentDocs(
|
|
|
114
114
|
function getVersionPathsToWatch(version: VersionMetadata): string[] {
|
|
115
115
|
const result = [
|
|
116
116
|
...options.include.flatMap((pattern) =>
|
|
117
|
-
|
|
117
|
+
getContentPathList(version).map(
|
|
118
118
|
(docsDirPath) => `${docsDirPath}/${pattern}`,
|
|
119
119
|
),
|
|
120
120
|
),
|
|
@@ -228,7 +228,7 @@ export default async function pluginContentDocs(
|
|
|
228
228
|
const tagsProp: PropTagsListPage['tags'] = Object.values(
|
|
229
229
|
versionTags,
|
|
230
230
|
).map((tagValue) => ({
|
|
231
|
-
name: tagValue.
|
|
231
|
+
name: tagValue.label,
|
|
232
232
|
permalink: tagValue.permalink,
|
|
233
233
|
count: tagValue.docIds.length,
|
|
234
234
|
}));
|
|
@@ -331,7 +331,7 @@ export default async function pluginContentDocs(
|
|
|
331
331
|
};
|
|
332
332
|
|
|
333
333
|
function createMDXLoaderRule(): RuleSetRule {
|
|
334
|
-
const contentDirs = versionsMetadata.flatMap(
|
|
334
|
+
const contentDirs = versionsMetadata.flatMap(getContentPathList);
|
|
335
335
|
return {
|
|
336
336
|
test: /\.mdx?$/i,
|
|
337
337
|
include: contentDirs
|
package/src/markdown/linkify.ts
CHANGED
|
@@ -6,12 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import type {DocsMarkdownOption} from '../types';
|
|
9
|
-
import {
|
|
10
|
-
import {replaceMarkdownLinks} from '@docusaurus/utils';
|
|
9
|
+
import {replaceMarkdownLinks, getContentPathList} from '@docusaurus/utils';
|
|
11
10
|
|
|
12
11
|
function getVersion(filePath: string, options: DocsMarkdownOption) {
|
|
13
12
|
const versionFound = options.versionsMetadata.find((version) =>
|
|
14
|
-
|
|
13
|
+
getContentPathList(version).some((docsDirPath) =>
|
|
15
14
|
filePath.startsWith(docsDirPath),
|
|
16
15
|
),
|
|
17
16
|
);
|