@docusaurus/plugin-client-redirects 4.0.0-canary-6870 → 4.0.0-canary-6873
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.
|
@@ -11,7 +11,7 @@ exports.toRedirectFiles = toRedirectFiles;
|
|
|
11
11
|
exports.default = writeRedirectFiles;
|
|
12
12
|
const tslib_1 = require("tslib");
|
|
13
13
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
14
|
-
const
|
|
14
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
15
15
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
16
16
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
17
17
|
const utils_1 = require("@docusaurus/utils");
|
|
@@ -31,8 +31,8 @@ function createToUrl(baseUrl, to) {
|
|
|
31
31
|
// See https://github.com/facebook/docusaurus/pull/5085
|
|
32
32
|
// See https://github.com/facebook/docusaurus/pull/5102
|
|
33
33
|
function getRedirectFilePath(fromPath, trailingSlash) {
|
|
34
|
-
const fileName =
|
|
35
|
-
const filePath =
|
|
34
|
+
const fileName = node_path_1.default.basename(fromPath);
|
|
35
|
+
const filePath = node_path_1.default.dirname(fromPath);
|
|
36
36
|
// Edge case for https://github.com/facebook/docusaurus/pull/5102
|
|
37
37
|
// If the redirect source path is /xyz, with file /xyz.html
|
|
38
38
|
// We can't write the redirect file at /xyz.html/index.html because for Unix
|
|
@@ -40,14 +40,14 @@ function getRedirectFilePath(fromPath, trailingSlash) {
|
|
|
40
40
|
// The only possible solution for a redirect file is thus /xyz.html.html (I
|
|
41
41
|
// know, looks suspicious)
|
|
42
42
|
if (trailingSlash === false && fileName.endsWith('.html')) {
|
|
43
|
-
return
|
|
43
|
+
return node_path_1.default.join(filePath, `${fileName}.html`);
|
|
44
44
|
}
|
|
45
45
|
// If the target path is /xyz, with file /xyz/index.html, we don't want the
|
|
46
46
|
// redirect file to be /xyz.html, otherwise it would be picked in priority and
|
|
47
47
|
// the redirect file would redirect to itself. We prefer the redirect file to
|
|
48
48
|
// be /xyz.html/index.html, served with lower priority for most static hosting
|
|
49
49
|
// tools
|
|
50
|
-
return
|
|
50
|
+
return node_path_1.default.join(filePath, `${fileName}/index.html`);
|
|
51
51
|
}
|
|
52
52
|
function toRedirectFiles(redirects, pluginContext, trailingSlash) {
|
|
53
53
|
// Perf: avoid rendering the template twice with the exact same "props"
|
|
@@ -56,7 +56,7 @@ function toRedirectFiles(redirects, pluginContext, trailingSlash) {
|
|
|
56
56
|
const createPageContentMemoized = lodash_1.default.memoize((toUrl) => (0, createRedirectPageContent_1.default)({ toUrl }));
|
|
57
57
|
const createFileMetadata = (redirect) => {
|
|
58
58
|
const fileRelativePath = getRedirectFilePath(redirect.from, trailingSlash);
|
|
59
|
-
const fileAbsolutePath =
|
|
59
|
+
const fileAbsolutePath = node_path_1.default.join(pluginContext.outDir, fileRelativePath);
|
|
60
60
|
const toUrl = createToUrl(pluginContext.baseUrl, redirect.to);
|
|
61
61
|
const fileContent = createPageContentMemoized(toUrl);
|
|
62
62
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-client-redirects",
|
|
3
|
-
"version": "4.0.0-canary-
|
|
3
|
+
"version": "4.0.0-canary-6873",
|
|
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": "4.0.0-canary-
|
|
22
|
-
"@docusaurus/logger": "4.0.0-canary-
|
|
23
|
-
"@docusaurus/utils": "4.0.0-canary-
|
|
24
|
-
"@docusaurus/utils-common": "4.0.0-canary-
|
|
25
|
-
"@docusaurus/utils-validation": "4.0.0-canary-
|
|
21
|
+
"@docusaurus/core": "4.0.0-canary-6873",
|
|
22
|
+
"@docusaurus/logger": "4.0.0-canary-6873",
|
|
23
|
+
"@docusaurus/utils": "4.0.0-canary-6873",
|
|
24
|
+
"@docusaurus/utils-common": "4.0.0-canary-6873",
|
|
25
|
+
"@docusaurus/utils-validation": "4.0.0-canary-6873",
|
|
26
26
|
"eta": "^4.6.0",
|
|
27
27
|
"fs-extra": "^11.4.0",
|
|
28
28
|
"lodash": "^4.18.1",
|
|
29
29
|
"tslib": "^2.8.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@docusaurus/types": "4.0.0-canary-
|
|
32
|
+
"@docusaurus/types": "4.0.0-canary-6873"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": "^19.3.0",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">=24.21"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "fdb1d5ba64c31fc9185a221a2e3f510e56b2c654"
|
|
42
42
|
}
|