@docusaurus/plugin-client-redirects 0.0.0-5133 → 0.0.0-5140
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 +5 -6
- package/lib/index.js +1 -0
- package/lib/types.d.ts +1 -1
- package/package.json +8 -8
- package/src/collectRedirects.ts +12 -10
- package/src/index.ts +1 -0
- package/src/types.ts +1 -1
package/lib/collectRedirects.js
CHANGED
|
@@ -73,17 +73,16 @@ function filterUnwantedRedirects(redirects, pluginContext) {
|
|
|
73
73
|
// writing the same html redirection file twice.
|
|
74
74
|
Object.entries(lodash_1.default.groupBy(redirects, (redirect) => redirect.from)).forEach(([from, groupedFromRedirects]) => {
|
|
75
75
|
if (groupedFromRedirects.length > 1) {
|
|
76
|
-
logger_1.default.
|
|
77
|
-
It is not possible to redirect the same pathname to multiple destinations
|
|
76
|
+
logger_1.default.report(pluginContext.siteConfig.onDuplicateRoutes) `name=${'@docusaurus/plugin-client-redirects'}: multiple redirects are created with the same "from" pathname: path=${from}
|
|
77
|
+
It is not possible to redirect the same pathname to multiple destinations:${groupedFromRedirects.map((r) => JSON.stringify(r))}`;
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
80
|
const collectedRedirects = lodash_1.default.uniqBy(redirects, (redirect) => redirect.from);
|
|
81
|
-
|
|
82
|
-
const redirectsOverridingExistingPath = collectedRedirects.filter((redirect) => pluginContext.relativeRoutesPaths.includes(redirect.from));
|
|
81
|
+
const { false: newRedirects = [], true: redirectsOverridingExistingPath = [] } = lodash_1.default.groupBy(collectedRedirects, (redirect) => pluginContext.relativeRoutesPaths.includes(redirect.from));
|
|
83
82
|
if (redirectsOverridingExistingPath.length > 0) {
|
|
84
|
-
logger_1.default.
|
|
83
|
+
logger_1.default.report(pluginContext.siteConfig.onDuplicateRoutes) `name=${'@docusaurus/plugin-client-redirects'}: some redirects would override existing paths, and will be ignored:${redirectsOverridingExistingPath.map((r) => JSON.stringify(r))}`;
|
|
85
84
|
}
|
|
86
|
-
return
|
|
85
|
+
return newRedirects;
|
|
87
86
|
}
|
|
88
87
|
function createRedirectsOptionRedirects(redirectsOption) {
|
|
89
88
|
// For convenience, user can use a string or a string[]
|
package/lib/index.js
CHANGED
|
@@ -21,6 +21,7 @@ function pluginClientRedirectsPages(context, options) {
|
|
|
21
21
|
baseUrl: props.baseUrl,
|
|
22
22
|
outDir: props.outDir,
|
|
23
23
|
options,
|
|
24
|
+
siteConfig: props.siteConfig,
|
|
24
25
|
};
|
|
25
26
|
const redirects = (0, collectRedirects_1.default)(pluginContext, trailingSlash);
|
|
26
27
|
const redirectFiles = (0, writeRedirectFiles_1.toRedirectFiles)(redirects, pluginContext, trailingSlash);
|
package/lib/types.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import type { PluginOptions } from './options';
|
|
|
9
9
|
/**
|
|
10
10
|
* The minimal infos the plugin needs to work
|
|
11
11
|
*/
|
|
12
|
-
export declare type PluginContext = Pick<Props, 'outDir' | 'baseUrl'> & {
|
|
12
|
+
export declare type PluginContext = Pick<Props, 'outDir' | 'baseUrl' | 'siteConfig'> & {
|
|
13
13
|
options: PluginOptions;
|
|
14
14
|
relativeRoutesPaths: string[];
|
|
15
15
|
};
|
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-5140",
|
|
4
4
|
"description": "Client redirects plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -18,18 +18,18 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/core": "0.0.0-
|
|
22
|
-
"@docusaurus/logger": "0.0.0-
|
|
23
|
-
"@docusaurus/utils": "0.0.0-
|
|
24
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
25
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
21
|
+
"@docusaurus/core": "0.0.0-5140",
|
|
22
|
+
"@docusaurus/logger": "0.0.0-5140",
|
|
23
|
+
"@docusaurus/utils": "0.0.0-5140",
|
|
24
|
+
"@docusaurus/utils-common": "0.0.0-5140",
|
|
25
|
+
"@docusaurus/utils-validation": "0.0.0-5140",
|
|
26
26
|
"eta": "^1.12.3",
|
|
27
27
|
"fs-extra": "^10.1.0",
|
|
28
28
|
"lodash": "^4.17.21",
|
|
29
29
|
"tslib": "^2.4.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@docusaurus/types": "0.0.0-
|
|
32
|
+
"@docusaurus/types": "0.0.0-5140"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": "^16.8.4 || ^17.0.0",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">=16.14"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "69c4afd865b2ddd33abeca82c6732b5d639e79d1"
|
|
42
42
|
}
|
package/src/collectRedirects.ts
CHANGED
|
@@ -102,8 +102,10 @@ function filterUnwantedRedirects(
|
|
|
102
102
|
Object.entries(_.groupBy(redirects, (redirect) => redirect.from)).forEach(
|
|
103
103
|
([from, groupedFromRedirects]) => {
|
|
104
104
|
if (groupedFromRedirects.length > 1) {
|
|
105
|
-
logger.
|
|
106
|
-
|
|
105
|
+
logger.report(
|
|
106
|
+
pluginContext.siteConfig.onDuplicateRoutes,
|
|
107
|
+
)`name=${'@docusaurus/plugin-client-redirects'}: multiple redirects are created with the same "from" pathname: path=${from}
|
|
108
|
+
It is not possible to redirect the same pathname to multiple destinations:${groupedFromRedirects.map(
|
|
107
109
|
(r) => JSON.stringify(r),
|
|
108
110
|
)}`;
|
|
109
111
|
}
|
|
@@ -111,18 +113,18 @@ It is not possible to redirect the same pathname to multiple destinations: ${gro
|
|
|
111
113
|
);
|
|
112
114
|
const collectedRedirects = _.uniqBy(redirects, (redirect) => redirect.from);
|
|
113
115
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
const {false: newRedirects = [], true: redirectsOverridingExistingPath = []} =
|
|
117
|
+
_.groupBy(collectedRedirects, (redirect) =>
|
|
118
|
+
pluginContext.relativeRoutesPaths.includes(redirect.from),
|
|
119
|
+
);
|
|
118
120
|
if (redirectsOverridingExistingPath.length > 0) {
|
|
119
|
-
logger.
|
|
121
|
+
logger.report(
|
|
122
|
+
pluginContext.siteConfig.onDuplicateRoutes,
|
|
123
|
+
)`name=${'@docusaurus/plugin-client-redirects'}: some redirects would override existing paths, and will be ignored:${redirectsOverridingExistingPath.map(
|
|
120
124
|
(r) => JSON.stringify(r),
|
|
121
125
|
)}`;
|
|
122
126
|
}
|
|
123
|
-
return
|
|
124
|
-
(redirect) => !pluginContext.relativeRoutesPaths.includes(redirect.from),
|
|
125
|
-
);
|
|
127
|
+
return newRedirects;
|
|
126
128
|
}
|
|
127
129
|
|
|
128
130
|
function createRedirectsOptionRedirects(
|
package/src/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type {PluginOptions} from './options';
|
|
|
11
11
|
/**
|
|
12
12
|
* The minimal infos the plugin needs to work
|
|
13
13
|
*/
|
|
14
|
-
export type PluginContext = Pick<Props, 'outDir' | 'baseUrl'> & {
|
|
14
|
+
export type PluginContext = Pick<Props, 'outDir' | 'baseUrl' | 'siteConfig'> & {
|
|
15
15
|
options: PluginOptions;
|
|
16
16
|
relativeRoutesPaths: string[];
|
|
17
17
|
};
|