@docusaurus/plugin-client-redirects 3.1.1 → 3.2.0
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 +6 -7
- package/lib/extensionRedirects.js +3 -3
- package/lib/index.js +2 -2
- package/package.json +8 -8
- package/src/collectRedirects.ts +5 -2
- package/src/extensionRedirects.ts +1 -1
- package/src/index.ts +1 -1
package/lib/collectRedirects.js
CHANGED
|
@@ -9,7 +9,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
const tslib_1 = require("tslib");
|
|
10
10
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
11
11
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
12
|
-
const utils_1 = require("@docusaurus/utils");
|
|
13
12
|
const utils_common_1 = require("@docusaurus/utils-common");
|
|
14
13
|
const extensionRedirects_1 = require("./extensionRedirects");
|
|
15
14
|
const redirectValidation_1 = require("./redirectValidation");
|
|
@@ -82,20 +81,20 @@ function validateCollectedRedirects(redirects, pluginContext) {
|
|
|
82
81
|
if (differByTrailSlash.has(toPath)) {
|
|
83
82
|
differByTrailSlash.delete(toPath);
|
|
84
83
|
}
|
|
85
|
-
else if (differByTrailSlash.has((0,
|
|
84
|
+
else if (differByTrailSlash.has((0, utils_common_1.removeTrailingSlash)(toPath))) {
|
|
86
85
|
if (trailingSlashConfig === true) {
|
|
87
|
-
differByTrailSlash.set((0,
|
|
86
|
+
differByTrailSlash.set((0, utils_common_1.removeTrailingSlash)(toPath), true);
|
|
88
87
|
}
|
|
89
88
|
else {
|
|
90
|
-
differByTrailSlash.delete((0,
|
|
89
|
+
differByTrailSlash.delete((0, utils_common_1.removeTrailingSlash)(toPath));
|
|
91
90
|
}
|
|
92
91
|
}
|
|
93
|
-
else if (differByTrailSlash.has((0,
|
|
92
|
+
else if (differByTrailSlash.has((0, utils_common_1.addTrailingSlash)(toPath))) {
|
|
94
93
|
if (trailingSlashConfig === false) {
|
|
95
|
-
differByTrailSlash.set((0,
|
|
94
|
+
differByTrailSlash.set((0, utils_common_1.addTrailingSlash)(toPath), true);
|
|
96
95
|
}
|
|
97
96
|
else {
|
|
98
|
-
differByTrailSlash.delete((0,
|
|
97
|
+
differByTrailSlash.delete((0, utils_common_1.addTrailingSlash)(toPath));
|
|
99
98
|
}
|
|
100
99
|
}
|
|
101
100
|
});
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.createFromExtensionsRedirects = exports.createToExtensionsRedirects = void 0;
|
|
10
|
-
const
|
|
10
|
+
const utils_common_1 = require("@docusaurus/utils-common");
|
|
11
11
|
const ExtensionAdditionalMessage = 'If the redirect extension system is not good enough for your use case, you can create redirects yourself with the "createRedirects" plugin option.';
|
|
12
12
|
const validateExtension = (ext) => {
|
|
13
13
|
if (!ext) {
|
|
@@ -33,7 +33,7 @@ function createToExtensionsRedirects(paths, extensions) {
|
|
|
33
33
|
const createPathRedirects = (path) => {
|
|
34
34
|
const extensionFound = dottedExtensions.find((ext) => path.endsWith(ext));
|
|
35
35
|
if (extensionFound) {
|
|
36
|
-
return [{ from: (0,
|
|
36
|
+
return [{ from: (0, utils_common_1.removeSuffix)(path, extensionFound), to: path }];
|
|
37
37
|
}
|
|
38
38
|
return [];
|
|
39
39
|
};
|
|
@@ -57,7 +57,7 @@ function createFromExtensionsRedirects(paths, extensions) {
|
|
|
57
57
|
// /path => /path.html
|
|
58
58
|
// /path/ => /path.html/
|
|
59
59
|
from: path.endsWith('/')
|
|
60
|
-
? (0,
|
|
60
|
+
? (0, utils_common_1.addTrailingSlash)(`${(0, utils_common_1.removeTrailingSlash)(path)}.${ext}`)
|
|
61
61
|
: `${path}.${ext}`,
|
|
62
62
|
to: path,
|
|
63
63
|
}));
|
package/lib/index.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.validateOptions = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
|
-
const
|
|
11
|
+
const utils_common_1 = require("@docusaurus/utils-common");
|
|
12
12
|
const collectRedirects_1 = tslib_1.__importDefault(require("./collectRedirects"));
|
|
13
13
|
const writeRedirectFiles_1 = tslib_1.__importStar(require("./writeRedirectFiles"));
|
|
14
14
|
function pluginClientRedirectsPages(context, options) {
|
|
@@ -17,7 +17,7 @@ function pluginClientRedirectsPages(context, options) {
|
|
|
17
17
|
name: 'docusaurus-plugin-client-redirects',
|
|
18
18
|
async postBuild(props) {
|
|
19
19
|
const pluginContext = {
|
|
20
|
-
relativeRoutesPaths: props.routesPaths.map((path) => `${(0,
|
|
20
|
+
relativeRoutesPaths: props.routesPaths.map((path) => `${(0, utils_common_1.addLeadingSlash)((0, utils_common_1.removePrefix)(path, props.baseUrl))}`),
|
|
21
21
|
baseUrl: props.baseUrl,
|
|
22
22
|
outDir: props.outDir,
|
|
23
23
|
options,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-client-redirects",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
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": "3.
|
|
22
|
-
"@docusaurus/logger": "3.
|
|
23
|
-
"@docusaurus/utils": "3.
|
|
24
|
-
"@docusaurus/utils-common": "3.
|
|
25
|
-
"@docusaurus/utils-validation": "3.
|
|
21
|
+
"@docusaurus/core": "3.2.0",
|
|
22
|
+
"@docusaurus/logger": "3.2.0",
|
|
23
|
+
"@docusaurus/utils": "3.2.0",
|
|
24
|
+
"@docusaurus/utils-common": "3.2.0",
|
|
25
|
+
"@docusaurus/utils-validation": "3.2.0",
|
|
26
26
|
"eta": "^2.2.0",
|
|
27
27
|
"fs-extra": "^11.1.1",
|
|
28
28
|
"lodash": "^4.17.21",
|
|
29
29
|
"tslib": "^2.6.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@docusaurus/types": "3.
|
|
32
|
+
"@docusaurus/types": "3.2.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": "^18.0.0",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">=18.0"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "5af143651b26b39761361acd96e9c5be7ba0cb25"
|
|
42
42
|
}
|
package/src/collectRedirects.ts
CHANGED
|
@@ -7,8 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
import _ from 'lodash';
|
|
9
9
|
import logger from '@docusaurus/logger';
|
|
10
|
-
import {
|
|
11
|
-
|
|
10
|
+
import {
|
|
11
|
+
applyTrailingSlash,
|
|
12
|
+
addTrailingSlash,
|
|
13
|
+
removeTrailingSlash,
|
|
14
|
+
} from '@docusaurus/utils-common';
|
|
12
15
|
import {
|
|
13
16
|
createFromExtensionsRedirects,
|
|
14
17
|
createToExtensionsRedirects,
|
package/src/index.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import {addLeadingSlash, removePrefix} from '@docusaurus/utils-common';
|
|
9
9
|
import collectRedirects from './collectRedirects';
|
|
10
10
|
import writeRedirectFiles, {
|
|
11
11
|
toRedirectFiles,
|