@docusaurus/plugin-client-redirects 0.0.0-4728 → 0.0.0-4730
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.
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
export default function createRedirectPageContent({ toUrl, }: {
|
|
8
8
|
toUrl: string;
|
|
9
|
-
};
|
|
10
|
-
export default function createRedirectPageContent({ toUrl, }: CreateRedirectPageOptions): string;
|
|
11
|
-
export {};
|
|
9
|
+
}): string;
|
package/lib/types.d.ts
CHANGED
|
@@ -6,11 +6,21 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { Props } from '@docusaurus/types';
|
|
8
8
|
import type { PluginOptions } from '@docusaurus/plugin-client-redirects';
|
|
9
|
+
/**
|
|
10
|
+
* The minimal infos the plugin needs to work
|
|
11
|
+
*/
|
|
9
12
|
export declare type PluginContext = Pick<Props, 'outDir' | 'baseUrl'> & {
|
|
10
13
|
options: PluginOptions;
|
|
11
14
|
relativeRoutesPaths: string[];
|
|
12
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* In-memory representation of redirects we want: easier to test
|
|
18
|
+
* /!\ easy to be confused: "from" is the new page we should create,
|
|
19
|
+
* that redirects to "to": the existing Docusaurus page
|
|
20
|
+
*/
|
|
13
21
|
export declare type RedirectMetadata = {
|
|
22
|
+
/** Pathname of the new page we should create */
|
|
14
23
|
from: string;
|
|
24
|
+
/** Pathname of an existing Docusaurus page */
|
|
15
25
|
to: string;
|
|
16
26
|
};
|
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-4730",
|
|
4
4
|
"description": "Client redirects plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/plugin-client-redirects.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-4730",
|
|
22
|
+
"@docusaurus/logger": "0.0.0-4730",
|
|
23
|
+
"@docusaurus/utils": "0.0.0-4730",
|
|
24
|
+
"@docusaurus/utils-common": "0.0.0-4730",
|
|
25
|
+
"@docusaurus/utils-validation": "0.0.0-4730",
|
|
26
26
|
"eta": "^1.12.3",
|
|
27
27
|
"fs-extra": "^10.0.1",
|
|
28
28
|
"lodash": "^4.17.21",
|
|
29
29
|
"tslib": "^2.3.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@docusaurus/types": "0.0.0-
|
|
32
|
+
"@docusaurus/types": "0.0.0-4730"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": "^16.8.4 || ^17.0.0",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">=14"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "65b87b9d9f21c7904877ed1fade98e0b9fb61b56"
|
|
42
42
|
}
|
|
@@ -9,10 +9,6 @@ import * as eta from 'eta';
|
|
|
9
9
|
import redirectPageTemplate from './templates/redirectPage.template.html';
|
|
10
10
|
import _ from 'lodash';
|
|
11
11
|
|
|
12
|
-
type CreateRedirectPageOptions = {
|
|
13
|
-
toUrl: string;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
12
|
const getCompiledRedirectPageTemplate = _.memoize(() =>
|
|
17
13
|
eta.compile(redirectPageTemplate.trim()),
|
|
18
14
|
);
|
|
@@ -24,7 +20,9 @@ function renderRedirectPageTemplate(data: Record<string, unknown>) {
|
|
|
24
20
|
|
|
25
21
|
export default function createRedirectPageContent({
|
|
26
22
|
toUrl,
|
|
27
|
-
}:
|
|
23
|
+
}: {
|
|
24
|
+
toUrl: string;
|
|
25
|
+
}): string {
|
|
28
26
|
return renderRedirectPageTemplate({
|
|
29
27
|
toUrl: encodeURI(toUrl),
|
|
30
28
|
});
|
|
@@ -10,18 +10,23 @@ export type RedirectOption = {
|
|
|
10
10
|
from: string | string[];
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
// For a given existing route path,
|
|
14
|
-
// return all the paths from which we should redirect from
|
|
15
|
-
export type CreateRedirectsFnOption = (
|
|
16
|
-
path: string,
|
|
17
|
-
) => string[] | string | null | undefined;
|
|
18
|
-
|
|
19
13
|
export type PluginOptions = {
|
|
14
|
+
/** Plugin ID. */
|
|
20
15
|
id: string;
|
|
16
|
+
/** The extensions to be removed from the route after redirecting. */
|
|
21
17
|
fromExtensions: string[];
|
|
18
|
+
/** The extensions to be appended to the route after redirecting. */
|
|
22
19
|
toExtensions: string[];
|
|
20
|
+
/** The list of redirect rules, each one with multiple `from`s → one `to`. */
|
|
23
21
|
redirects: RedirectOption[];
|
|
24
|
-
|
|
22
|
+
/**
|
|
23
|
+
* A callback to create a redirect rule.
|
|
24
|
+
* @returns All the paths from which we should redirect to `path`
|
|
25
|
+
*/
|
|
26
|
+
createRedirects?: (
|
|
27
|
+
/** An existing Docusaurus route path */
|
|
28
|
+
path: string,
|
|
29
|
+
) => string[] | string | null | undefined;
|
|
25
30
|
};
|
|
26
31
|
|
|
27
32
|
export type Options = Partial<PluginOptions>;
|
package/src/types.ts
CHANGED
|
@@ -8,16 +8,22 @@
|
|
|
8
8
|
import type {Props} from '@docusaurus/types';
|
|
9
9
|
import type {PluginOptions} from '@docusaurus/plugin-client-redirects';
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* The minimal infos the plugin needs to work
|
|
13
|
+
*/
|
|
12
14
|
export type PluginContext = Pick<Props, 'outDir' | 'baseUrl'> & {
|
|
13
15
|
options: PluginOptions;
|
|
14
16
|
relativeRoutesPaths: string[];
|
|
15
17
|
};
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
/**
|
|
20
|
+
* In-memory representation of redirects we want: easier to test
|
|
21
|
+
* /!\ easy to be confused: "from" is the new page we should create,
|
|
22
|
+
* that redirects to "to": the existing Docusaurus page
|
|
23
|
+
*/
|
|
20
24
|
export type RedirectMetadata = {
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
/** Pathname of the new page we should create */
|
|
26
|
+
from: string;
|
|
27
|
+
/** Pathname of an existing Docusaurus page */
|
|
28
|
+
to: string;
|
|
23
29
|
};
|