@docusaurus/plugin-client-redirects 2.0.0-beta.18 → 2.0.0-beta.19

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.
@@ -65,8 +65,8 @@ Valid paths you can redirect to:
65
65
  }
66
66
  }
67
67
  function filterUnwantedRedirects(redirects, pluginContext) {
68
- // we don't want to create twice the same redirect
69
- // that would lead to writing twice the same html redirection file
68
+ // We don't want to create the same redirect twice, since that would lead to
69
+ // writing the same html redirection file twice.
70
70
  Object.entries(lodash_1.default.groupBy(redirects, (redirect) => redirect.from)).forEach(([from, groupedFromRedirects]) => {
71
71
  if (groupedFromRedirects.length > 1) {
72
72
  logger_1.default.error `name=${'@docusaurus/plugin-client-redirects'}: multiple redirects are created with the same "from" pathname: path=${from}
package/lib/index.d.ts CHANGED
@@ -5,6 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { LoadContext, Plugin } from '@docusaurus/types';
8
- import type { PluginOptions } from '@docusaurus/plugin-client-redirects';
8
+ import type { PluginOptions, Options } from './options';
9
9
  export default function pluginClientRedirectsPages(context: LoadContext, options: PluginOptions): Plugin<unknown>;
10
10
  export { validateOptions } from './options';
11
+ export type { PluginOptions, Options };
package/lib/options.d.ts CHANGED
@@ -4,7 +4,28 @@
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
- import type { PluginOptions, Options } from '@docusaurus/plugin-client-redirects';
8
7
  import type { OptionValidationContext } from '@docusaurus/types';
8
+ export declare type RedirectOption = {
9
+ to: string;
10
+ from: string | string[];
11
+ };
12
+ export declare type PluginOptions = {
13
+ /** Plugin ID. */
14
+ id: string;
15
+ /** The extensions to be removed from the route after redirecting. */
16
+ fromExtensions: string[];
17
+ /** The extensions to be appended to the route after redirecting. */
18
+ toExtensions: string[];
19
+ /** The list of redirect rules, each one with multiple `from`s → one `to`. */
20
+ redirects: RedirectOption[];
21
+ /**
22
+ * A callback to create a redirect rule.
23
+ * @returns All the paths from which we should redirect to `path`
24
+ */
25
+ createRedirects?: (
26
+ /** An existing Docusaurus route path */
27
+ path: string) => string[] | string | null | undefined;
28
+ };
29
+ export declare type Options = Partial<PluginOptions>;
9
30
  export declare const DEFAULT_OPTIONS: Partial<PluginOptions>;
10
31
  export declare function validateOptions({ validate, options: userOptions, }: OptionValidationContext<Options, PluginOptions>): PluginOptions;
package/lib/types.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { Props } from '@docusaurus/types';
8
- import type { PluginOptions } from '@docusaurus/plugin-client-redirects';
8
+ import type { PluginOptions } from './options';
9
9
  /**
10
10
  * The minimal infos the plugin needs to work
11
11
  */
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-client-redirects",
3
- "version": "2.0.0-beta.18",
3
+ "version": "2.0.0-beta.19",
4
4
  "description": "Client redirects plugin for Docusaurus.",
5
5
  "main": "lib/index.js",
6
- "types": "src/plugin-client-redirects.d.ts",
6
+ "types": "lib/index.d.ts",
7
7
  "scripts": {
8
8
  "build": "tsc",
9
9
  "watch": "tsc --watch"
@@ -18,18 +18,18 @@
18
18
  },
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "@docusaurus/core": "2.0.0-beta.18",
22
- "@docusaurus/logger": "2.0.0-beta.18",
23
- "@docusaurus/utils": "2.0.0-beta.18",
24
- "@docusaurus/utils-common": "2.0.0-beta.18",
25
- "@docusaurus/utils-validation": "2.0.0-beta.18",
21
+ "@docusaurus/core": "2.0.0-beta.19",
22
+ "@docusaurus/logger": "2.0.0-beta.19",
23
+ "@docusaurus/utils": "2.0.0-beta.19",
24
+ "@docusaurus/utils-common": "2.0.0-beta.19",
25
+ "@docusaurus/utils-validation": "2.0.0-beta.19",
26
26
  "eta": "^1.12.3",
27
- "fs-extra": "^10.0.1",
27
+ "fs-extra": "^10.1.0",
28
28
  "lodash": "^4.17.21",
29
- "tslib": "^2.3.1"
29
+ "tslib": "^2.4.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@docusaurus/types": "2.0.0-beta.18"
32
+ "@docusaurus/types": "2.0.0-beta.19"
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": "1a945d06993d53376e61bed2c942799fe07dc336"
41
+ "gitHead": "a71e60a49cce93c1006ef10c41ac03187f057102"
42
42
  }
@@ -6,10 +6,7 @@
6
6
  */
7
7
 
8
8
  import _ from 'lodash';
9
- import type {
10
- PluginOptions,
11
- RedirectOption,
12
- } from '@docusaurus/plugin-client-redirects';
9
+ import type {PluginOptions, RedirectOption} from './options';
13
10
  import type {PluginContext, RedirectMetadata} from './types';
14
11
  import {
15
12
  createFromExtensionsRedirects,
@@ -96,8 +93,8 @@ function filterUnwantedRedirects(
96
93
  redirects: RedirectMetadata[],
97
94
  pluginContext: PluginContext,
98
95
  ): RedirectMetadata[] {
99
- // we don't want to create twice the same redirect
100
- // that would lead to writing twice the same html redirection file
96
+ // We don't want to create the same redirect twice, since that would lead to
97
+ // writing the same html redirection file twice.
101
98
  Object.entries(_.groupBy(redirects, (redirect) => redirect.from)).forEach(
102
99
  ([from, groupedFromRedirects]) => {
103
100
  if (groupedFromRedirects.length > 1) {
package/src/index.ts CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  import type {LoadContext, Plugin} from '@docusaurus/types';
9
9
  import type {PluginContext, RedirectMetadata} from './types';
10
- import type {PluginOptions} from '@docusaurus/plugin-client-redirects';
10
+ import type {PluginOptions, Options} from './options';
11
11
 
12
12
  import collectRedirects from './collectRedirects';
13
13
  import writeRedirectFiles, {
@@ -52,3 +52,4 @@ export default function pluginClientRedirectsPages(
52
52
  }
53
53
 
54
54
  export {validateOptions} from './options';
55
+ export type {PluginOptions, Options};
package/src/options.ts CHANGED
@@ -5,14 +5,35 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import type {
9
- PluginOptions,
10
- Options,
11
- RedirectOption,
12
- } from '@docusaurus/plugin-client-redirects';
13
8
  import type {OptionValidationContext} from '@docusaurus/types';
14
9
  import {Joi, PathnameSchema} from '@docusaurus/utils-validation';
15
10
 
11
+ export type RedirectOption = {
12
+ to: string;
13
+ from: string | string[];
14
+ };
15
+
16
+ export type PluginOptions = {
17
+ /** Plugin ID. */
18
+ id: string;
19
+ /** The extensions to be removed from the route after redirecting. */
20
+ fromExtensions: string[];
21
+ /** The extensions to be appended to the route after redirecting. */
22
+ toExtensions: string[];
23
+ /** The list of redirect rules, each one with multiple `from`s → one `to`. */
24
+ redirects: RedirectOption[];
25
+ /**
26
+ * A callback to create a redirect rule.
27
+ * @returns All the paths from which we should redirect to `path`
28
+ */
29
+ createRedirects?: (
30
+ /** An existing Docusaurus route path */
31
+ path: string,
32
+ ) => string[] | string | null | undefined;
33
+ };
34
+
35
+ export type Options = Partial<PluginOptions>;
36
+
16
37
  export const DEFAULT_OPTIONS: Partial<PluginOptions> = {
17
38
  fromExtensions: [],
18
39
  toExtensions: [],
package/src/types.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import type {Props} from '@docusaurus/types';
9
- import type {PluginOptions} from '@docusaurus/plugin-client-redirects';
9
+ import type {PluginOptions} from './options';
10
10
 
11
11
  /**
12
12
  * The minimal infos the plugin needs to work
@@ -1,32 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- export type RedirectOption = {
9
- to: string;
10
- from: string | string[];
11
- };
12
-
13
- export type PluginOptions = {
14
- /** Plugin ID. */
15
- id: string;
16
- /** The extensions to be removed from the route after redirecting. */
17
- fromExtensions: string[];
18
- /** The extensions to be appended to the route after redirecting. */
19
- toExtensions: string[];
20
- /** The list of redirect rules, each one with multiple `from`s → one `to`. */
21
- redirects: RedirectOption[];
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;
30
- };
31
-
32
- export type Options = Partial<PluginOptions>;