@docusaurus/plugin-content-docs 3.8.1-canary-6361 → 3.8.1-canary-6364
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.js +1 -1
- package/lib/docs.js +2 -1
- package/lib/versions/files.js +8 -5
- package/lib/versions/version.js +26 -16
- package/package.json +11 -11
- package/src/cli.ts +2 -2
- package/src/docs.ts +3 -1
- package/src/versions/files.ts +15 -6
- package/src/versions/version.ts +37 -23
package/lib/cli.js
CHANGED
|
@@ -49,7 +49,7 @@ async function cliDocsVersionCommand(version, { id: pluginId, path: docsPath, si
|
|
|
49
49
|
logger_1.default.info `Versioned docs will be created for the following locales: name=${i18n.locales}`;
|
|
50
50
|
}
|
|
51
51
|
await Promise.all(i18n.locales.map(async (locale) => {
|
|
52
|
-
const localizationDir = path_1.default.resolve(siteDir, i18n.path, i18n
|
|
52
|
+
const localizationDir = path_1.default.resolve(siteDir, i18n.path, (0, utils_1.getLocaleConfig)(i18n, locale).path);
|
|
53
53
|
// Copy docs files.
|
|
54
54
|
const docsDir = locale === i18n.defaultLocale
|
|
55
55
|
? path_1.default.resolve(siteDir, docsPath)
|
package/lib/docs.js
CHANGED
|
@@ -103,7 +103,8 @@ async function doProcessDocMetadata({ docFile, versionMetadata, context, options
|
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
105
|
else if (typeof options.editUrl === 'string') {
|
|
106
|
-
const isLocalized =
|
|
106
|
+
const isLocalized = typeof versionMetadata.contentPathLocalized !== 'undefined' &&
|
|
107
|
+
contentPath === versionMetadata.contentPathLocalized;
|
|
107
108
|
const baseVersionEditUrl = isLocalized && options.editLocalizedFiles
|
|
108
109
|
? versionMetadata.editUrlLocalized
|
|
109
110
|
: versionMetadata.editUrl;
|
package/lib/versions/files.js
CHANGED
|
@@ -117,11 +117,14 @@ async function readVersionNames(siteDir, options) {
|
|
|
117
117
|
*/
|
|
118
118
|
async function getVersionMetadataPaths({ versionName, context, options, }) {
|
|
119
119
|
const isCurrent = versionName === constants_1.CURRENT_VERSION_NAME;
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
120
|
+
const shouldTranslate = (0, utils_1.getLocaleConfig)(context.i18n).translate;
|
|
121
|
+
const contentPathLocalized = shouldTranslate
|
|
122
|
+
? getDocsDirPathLocalized({
|
|
123
|
+
localizationDir: context.localizationDir,
|
|
124
|
+
pluginId: options.id,
|
|
125
|
+
versionName,
|
|
126
|
+
})
|
|
127
|
+
: undefined;
|
|
125
128
|
const contentPath = isCurrent
|
|
126
129
|
? path_1.default.resolve(context.siteDir, options.path)
|
|
127
130
|
: getVersionDocsDirPath(context.siteDir, options.id, versionName);
|
package/lib/versions/version.js
CHANGED
|
@@ -28,22 +28,32 @@ function getVersionEditUrls({ contentPath, contentPathLocalized, context, option
|
|
|
28
28
|
if (!options.editUrl || typeof options.editUrl === 'function') {
|
|
29
29
|
return { editUrl: undefined, editUrlLocalized: undefined };
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
31
|
+
// Intermediate var just to please TS not narrowing to "string"
|
|
32
|
+
const editUrlOption = options.editUrl;
|
|
33
|
+
const getEditUrl = () => {
|
|
34
|
+
const editDirPath = options.editCurrentVersion ? options.path : contentPath;
|
|
35
|
+
return (0, utils_1.normalizeUrl)([
|
|
36
|
+
editUrlOption,
|
|
37
|
+
(0, utils_1.posixPath)(path_1.default.relative(context.siteDir, path_1.default.resolve(context.siteDir, editDirPath))),
|
|
38
|
+
]);
|
|
39
|
+
};
|
|
40
|
+
const getEditUrlLocalized = () => {
|
|
41
|
+
if (!contentPathLocalized) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
const editDirPathLocalized = options.editCurrentVersion
|
|
45
|
+
? (0, files_1.getDocsDirPathLocalized)({
|
|
46
|
+
localizationDir: context.localizationDir,
|
|
47
|
+
versionName: constants_1.CURRENT_VERSION_NAME,
|
|
48
|
+
pluginId: options.id,
|
|
49
|
+
})
|
|
50
|
+
: contentPathLocalized;
|
|
51
|
+
return (0, utils_1.normalizeUrl)([
|
|
52
|
+
editUrlOption,
|
|
53
|
+
(0, utils_1.posixPath)(path_1.default.relative(context.siteDir, path_1.default.resolve(context.siteDir, editDirPathLocalized))),
|
|
54
|
+
]);
|
|
55
|
+
};
|
|
56
|
+
return { editUrl: getEditUrl(), editUrlLocalized: getEditUrlLocalized() };
|
|
47
57
|
}
|
|
48
58
|
/**
|
|
49
59
|
* The default version banner depends on the version's relative position to the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-content-docs",
|
|
3
|
-
"version": "3.8.1-canary-
|
|
3
|
+
"version": "3.8.1-canary-6364",
|
|
4
4
|
"description": "Docs plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
},
|
|
36
36
|
"license": "MIT",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@docusaurus/core": "3.8.1-canary-
|
|
39
|
-
"@docusaurus/logger": "3.8.1-canary-
|
|
40
|
-
"@docusaurus/mdx-loader": "3.8.1-canary-
|
|
41
|
-
"@docusaurus/module-type-aliases": "3.8.1-canary-
|
|
42
|
-
"@docusaurus/theme-common": "3.8.1-canary-
|
|
43
|
-
"@docusaurus/types": "3.8.1-canary-
|
|
44
|
-
"@docusaurus/utils": "3.8.1-canary-
|
|
45
|
-
"@docusaurus/utils-common": "3.8.1-canary-
|
|
46
|
-
"@docusaurus/utils-validation": "3.8.1-canary-
|
|
38
|
+
"@docusaurus/core": "3.8.1-canary-6364",
|
|
39
|
+
"@docusaurus/logger": "3.8.1-canary-6364",
|
|
40
|
+
"@docusaurus/mdx-loader": "3.8.1-canary-6364",
|
|
41
|
+
"@docusaurus/module-type-aliases": "3.8.1-canary-6364",
|
|
42
|
+
"@docusaurus/theme-common": "3.8.1-canary-6364",
|
|
43
|
+
"@docusaurus/types": "3.8.1-canary-6364",
|
|
44
|
+
"@docusaurus/utils": "3.8.1-canary-6364",
|
|
45
|
+
"@docusaurus/utils-common": "3.8.1-canary-6364",
|
|
46
|
+
"@docusaurus/utils-validation": "3.8.1-canary-6364",
|
|
47
47
|
"@types/react-router-config": "^5.0.7",
|
|
48
48
|
"combine-promises": "^1.1.0",
|
|
49
49
|
"fs-extra": "^11.1.1",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"engines": {
|
|
68
68
|
"node": ">=18.0"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "eb21e3eaf84009a29feff55780bb5d3a76658d01"
|
|
71
71
|
}
|
package/src/cli.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import fs from 'fs-extra';
|
|
9
9
|
import path from 'path';
|
|
10
10
|
import logger from '@docusaurus/logger';
|
|
11
|
-
import {DEFAULT_PLUGIN_ID} from '@docusaurus/utils';
|
|
11
|
+
import {DEFAULT_PLUGIN_ID, getLocaleConfig} from '@docusaurus/utils';
|
|
12
12
|
import {
|
|
13
13
|
getVersionsFilePath,
|
|
14
14
|
getVersionDocsDirPath,
|
|
@@ -89,7 +89,7 @@ async function cliDocsVersionCommand(
|
|
|
89
89
|
const localizationDir = path.resolve(
|
|
90
90
|
siteDir,
|
|
91
91
|
i18n.path,
|
|
92
|
-
i18n.
|
|
92
|
+
getLocaleConfig(i18n, locale).path,
|
|
93
93
|
);
|
|
94
94
|
// Copy docs files.
|
|
95
95
|
const docsDir =
|
package/src/docs.ts
CHANGED
|
@@ -196,7 +196,9 @@ async function doProcessDocMetadata({
|
|
|
196
196
|
locale: context.i18n.currentLocale,
|
|
197
197
|
});
|
|
198
198
|
} else if (typeof options.editUrl === 'string') {
|
|
199
|
-
const isLocalized =
|
|
199
|
+
const isLocalized =
|
|
200
|
+
typeof versionMetadata.contentPathLocalized !== 'undefined' &&
|
|
201
|
+
contentPath === versionMetadata.contentPathLocalized;
|
|
200
202
|
const baseVersionEditUrl =
|
|
201
203
|
isLocalized && options.editLocalizedFiles
|
|
202
204
|
? versionMetadata.editUrlLocalized
|
package/src/versions/files.ts
CHANGED
|
@@ -7,7 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
import path from 'path';
|
|
9
9
|
import fs from 'fs-extra';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
getPluginI18nPath,
|
|
12
|
+
getLocaleConfig,
|
|
13
|
+
DEFAULT_PLUGIN_ID,
|
|
14
|
+
} from '@docusaurus/utils';
|
|
11
15
|
import {
|
|
12
16
|
VERSIONS_JSON_FILE,
|
|
13
17
|
VERSIONED_DOCS_DIR,
|
|
@@ -186,11 +190,16 @@ export async function getVersionMetadataPaths({
|
|
|
186
190
|
>
|
|
187
191
|
> {
|
|
188
192
|
const isCurrent = versionName === CURRENT_VERSION_NAME;
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
193
|
+
|
|
194
|
+
const shouldTranslate = getLocaleConfig(context.i18n).translate;
|
|
195
|
+
const contentPathLocalized = shouldTranslate
|
|
196
|
+
? getDocsDirPathLocalized({
|
|
197
|
+
localizationDir: context.localizationDir,
|
|
198
|
+
pluginId: options.id,
|
|
199
|
+
versionName,
|
|
200
|
+
})
|
|
201
|
+
: undefined;
|
|
202
|
+
|
|
194
203
|
const contentPath = isCurrent
|
|
195
204
|
? path.resolve(context.siteDir, options.path)
|
|
196
205
|
: getVersionDocsDirPath(context.siteDir, options.id, versionName);
|
package/src/versions/version.ts
CHANGED
|
@@ -50,33 +50,47 @@ function getVersionEditUrls({
|
|
|
50
50
|
return {editUrl: undefined, editUrlLocalized: undefined};
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
? getDocsDirPathLocalized({
|
|
56
|
-
localizationDir: context.localizationDir,
|
|
57
|
-
versionName: CURRENT_VERSION_NAME,
|
|
58
|
-
pluginId: options.id,
|
|
59
|
-
})
|
|
60
|
-
: contentPathLocalized;
|
|
53
|
+
// Intermediate var just to please TS not narrowing to "string"
|
|
54
|
+
const editUrlOption = options.editUrl;
|
|
61
55
|
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
56
|
+
const getEditUrl = () => {
|
|
57
|
+
const editDirPath = options.editCurrentVersion ? options.path : contentPath;
|
|
58
|
+
|
|
59
|
+
return normalizeUrl([
|
|
60
|
+
editUrlOption,
|
|
61
|
+
posixPath(
|
|
62
|
+
path.relative(
|
|
63
|
+
context.siteDir,
|
|
64
|
+
path.resolve(context.siteDir, editDirPath),
|
|
65
|
+
),
|
|
66
|
+
),
|
|
67
|
+
]);
|
|
68
|
+
};
|
|
71
69
|
|
|
72
|
-
const
|
|
70
|
+
const getEditUrlLocalized = () => {
|
|
71
|
+
if (!contentPathLocalized) {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
const editDirPathLocalized = options.editCurrentVersion
|
|
75
|
+
? getDocsDirPathLocalized({
|
|
76
|
+
localizationDir: context.localizationDir,
|
|
77
|
+
versionName: CURRENT_VERSION_NAME,
|
|
78
|
+
pluginId: options.id,
|
|
79
|
+
})
|
|
80
|
+
: contentPathLocalized;
|
|
73
81
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
82
|
+
return normalizeUrl([
|
|
83
|
+
editUrlOption,
|
|
84
|
+
posixPath(
|
|
85
|
+
path.relative(
|
|
86
|
+
context.siteDir,
|
|
87
|
+
path.resolve(context.siteDir, editDirPathLocalized),
|
|
88
|
+
),
|
|
89
|
+
),
|
|
90
|
+
]);
|
|
91
|
+
};
|
|
78
92
|
|
|
79
|
-
return {editUrl, editUrlLocalized};
|
|
93
|
+
return {editUrl: getEditUrl(), editUrlLocalized: getEditUrlLocalized()};
|
|
80
94
|
}
|
|
81
95
|
|
|
82
96
|
/**
|