@docusaurus/plugin-client-redirects 0.0.0-4289 → 0.0.0-4298
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/collectRedirects.js +4 -8
- package/package.json +8 -7
- package/src/collectRedirects.ts +8 -16
package/lib/collectRedirects.js
CHANGED
|
@@ -11,7 +11,7 @@ const lodash_1 = require("lodash");
|
|
|
11
11
|
const extensionRedirects_1 = require("./extensionRedirects");
|
|
12
12
|
const redirectValidation_1 = require("./redirectValidation");
|
|
13
13
|
const utils_common_1 = require("@docusaurus/utils-common");
|
|
14
|
-
const
|
|
14
|
+
const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
|
|
15
15
|
function collectRedirects(pluginContext, trailingSlash) {
|
|
16
16
|
let redirects = doCollectRedirects(pluginContext);
|
|
17
17
|
redirects = applyRedirectsTrailingSlash(redirects, {
|
|
@@ -66,19 +66,15 @@ function filterUnwantedRedirects(redirects, pluginContext) {
|
|
|
66
66
|
// that would lead to writing twice the same html redirection file
|
|
67
67
|
Object.entries((0, lodash_1.groupBy)(redirects, (redirect) => redirect.from)).forEach(([from, groupedFromRedirects]) => {
|
|
68
68
|
if (groupedFromRedirects.length > 1) {
|
|
69
|
-
|
|
70
|
-
It is not possible to redirect the same pathname to multiple destinations:
|
|
71
|
-
- ${groupedFromRedirects.map((r) => JSON.stringify(r)).join('\n- ')}
|
|
72
|
-
`));
|
|
69
|
+
logger_1.default.error `name=${'@docusaurus/plugin-client-redirects'}: multiple redirects are created with the same "from" pathname: path=${from}
|
|
70
|
+
It is not possible to redirect the same pathname to multiple destinations: ${groupedFromRedirects.map((r) => JSON.stringify(r))}`;
|
|
73
71
|
}
|
|
74
72
|
});
|
|
75
73
|
const collectedRedirects = (0, lodash_1.uniqBy)(redirects, (redirect) => redirect.from);
|
|
76
74
|
// We don't want to override an already existing route with a redirect file!
|
|
77
75
|
const redirectsOverridingExistingPath = collectedRedirects.filter((redirect) => pluginContext.relativeRoutesPaths.includes(redirect.from));
|
|
78
76
|
if (redirectsOverridingExistingPath.length > 0) {
|
|
79
|
-
|
|
80
|
-
- ${redirectsOverridingExistingPath.map((r) => JSON.stringify(r)).join('\n- ')}
|
|
81
|
-
`));
|
|
77
|
+
logger_1.default.error `name=${'@docusaurus/plugin-client-redirects'}: some redirects would override existing paths, and will be ignored: ${redirectsOverridingExistingPath.map((r) => JSON.stringify(r))}`;
|
|
82
78
|
}
|
|
83
79
|
return collectedRedirects.filter((redirect) => !pluginContext.relativeRoutesPaths.includes(redirect.from));
|
|
84
80
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-client-redirects",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-4298",
|
|
4
4
|
"description": "Client redirects plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/plugin-client-redirects.d.ts",
|
|
@@ -18,10 +18,11 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/core": "0.0.0-
|
|
22
|
-
"@docusaurus/
|
|
23
|
-
"@docusaurus/utils
|
|
24
|
-
"@docusaurus/utils-
|
|
21
|
+
"@docusaurus/core": "0.0.0-4298",
|
|
22
|
+
"@docusaurus/logger": "0.0.0-4298",
|
|
23
|
+
"@docusaurus/utils": "0.0.0-4298",
|
|
24
|
+
"@docusaurus/utils-common": "0.0.0-4298",
|
|
25
|
+
"@docusaurus/utils-validation": "0.0.0-4298",
|
|
25
26
|
"chalk": "^4.1.2",
|
|
26
27
|
"eta": "^1.12.3",
|
|
27
28
|
"fs-extra": "^10.0.0",
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
"tslib": "^2.3.1"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"@docusaurus/types": "0.0.0-
|
|
33
|
+
"@docusaurus/types": "0.0.0-4298"
|
|
33
34
|
},
|
|
34
35
|
"peerDependencies": {
|
|
35
36
|
"react": "^16.8.4 || ^17.0.0",
|
|
@@ -38,5 +39,5 @@
|
|
|
38
39
|
"engines": {
|
|
39
40
|
"node": ">=14"
|
|
40
41
|
},
|
|
41
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "ca4920916dff261f4dbffd3b2465a5aac3a66c3f"
|
|
42
43
|
}
|
package/src/collectRedirects.ts
CHANGED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
ApplyTrailingSlashParams,
|
|
23
23
|
} from '@docusaurus/utils-common';
|
|
24
24
|
|
|
25
|
-
import
|
|
25
|
+
import logger from '@docusaurus/logger';
|
|
26
26
|
|
|
27
27
|
export default function collectRedirects(
|
|
28
28
|
pluginContext: PluginContext,
|
|
@@ -99,14 +99,10 @@ function filterUnwantedRedirects(
|
|
|
99
99
|
Object.entries(groupBy(redirects, (redirect) => redirect.from)).forEach(
|
|
100
100
|
([from, groupedFromRedirects]) => {
|
|
101
101
|
if (groupedFromRedirects.length > 1) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
- ${groupedFromRedirects.map((r) => JSON.stringify(r)).join('\n- ')}
|
|
107
|
-
`,
|
|
108
|
-
),
|
|
109
|
-
);
|
|
102
|
+
logger.error`name=${'@docusaurus/plugin-client-redirects'}: multiple redirects are created with the same "from" pathname: path=${from}
|
|
103
|
+
It is not possible to redirect the same pathname to multiple destinations: ${groupedFromRedirects.map(
|
|
104
|
+
(r) => JSON.stringify(r),
|
|
105
|
+
)}`;
|
|
110
106
|
}
|
|
111
107
|
},
|
|
112
108
|
);
|
|
@@ -117,13 +113,9 @@ It is not possible to redirect the same pathname to multiple destinations:
|
|
|
117
113
|
(redirect) => pluginContext.relativeRoutesPaths.includes(redirect.from),
|
|
118
114
|
);
|
|
119
115
|
if (redirectsOverridingExistingPath.length > 0) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
- ${redirectsOverridingExistingPath.map((r) => JSON.stringify(r)).join('\n- ')}
|
|
124
|
-
`,
|
|
125
|
-
),
|
|
126
|
-
);
|
|
116
|
+
logger.error`name=${'@docusaurus/plugin-client-redirects'}: some redirects would override existing paths, and will be ignored: ${redirectsOverridingExistingPath.map(
|
|
117
|
+
(r) => JSON.stringify(r),
|
|
118
|
+
)}`;
|
|
127
119
|
}
|
|
128
120
|
return collectedRedirects.filter(
|
|
129
121
|
(redirect) => !pluginContext.relativeRoutesPaths.includes(redirect.from),
|