@docusaurus/plugin-content-pages 0.0.0-4752 → 0.0.0-4753
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/{pageFrontMatter.d.ts → frontMatter.d.ts} +0 -0
- package/lib/{pageFrontMatter.js → frontMatter.js} +0 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.js +5 -9
- package/lib/options.d.ts +10 -0
- package/lib/{pluginOptionSchema.js → options.js} +7 -2
- package/package.json +7 -7
- package/src/{pageFrontMatter.ts → frontMatter.ts} +0 -0
- package/src/index.ts +4 -16
- package/src/{pluginOptionSchema.ts → options.ts} +11 -2
- package/lib/pluginOptionSchema.d.ts +0 -10
|
File without changes
|
|
File without changes
|
package/lib/index.d.ts
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
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 { LoadContext, Plugin
|
|
7
|
+
import type { LoadContext, Plugin } from '@docusaurus/types';
|
|
8
8
|
import type { LoadedContent, PagesContentPaths } from './types';
|
|
9
9
|
import type { PluginOptions } from '@docusaurus/plugin-content-pages';
|
|
10
10
|
export declare function getContentPathList(contentPaths: PagesContentPaths): string[];
|
|
11
11
|
export default function pluginContentPages(context: LoadContext, options: PluginOptions): Promise<Plugin<LoadedContent | null>>;
|
|
12
|
-
export
|
|
12
|
+
export { validateOptions } from './options';
|
package/lib/index.js
CHANGED
|
@@ -12,8 +12,7 @@ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
|
12
12
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
13
13
|
const utils_1 = require("@docusaurus/utils");
|
|
14
14
|
const remark_admonitions_1 = tslib_1.__importDefault(require("remark-admonitions"));
|
|
15
|
-
const
|
|
16
|
-
const pageFrontMatter_1 = require("./pageFrontMatter");
|
|
15
|
+
const frontMatter_1 = require("./frontMatter");
|
|
17
16
|
function getContentPathList(contentPaths) {
|
|
18
17
|
return [contentPaths.contentPathLocalized, contentPaths.contentPath];
|
|
19
18
|
}
|
|
@@ -72,7 +71,7 @@ async function pluginContentPages(context, options) {
|
|
|
72
71
|
}
|
|
73
72
|
const content = await fs_extra_1.default.readFile(source, 'utf-8');
|
|
74
73
|
const { frontMatter: unsafeFrontMatter, contentTitle, excerpt, } = (0, utils_1.parseMarkdownString)(content);
|
|
75
|
-
const frontMatter = (0,
|
|
74
|
+
const frontMatter = (0, frontMatter_1.validatePageFrontMatter)(unsafeFrontMatter);
|
|
76
75
|
return {
|
|
77
76
|
type: 'mdx',
|
|
78
77
|
permalink,
|
|
@@ -117,7 +116,7 @@ async function pluginContentPages(context, options) {
|
|
|
117
116
|
}
|
|
118
117
|
}));
|
|
119
118
|
},
|
|
120
|
-
configureWebpack(
|
|
119
|
+
configureWebpack(config, isServer, { getJSLoader }) {
|
|
121
120
|
const { rehypePlugins, remarkPlugins, beforeDefaultRehypePlugins, beforeDefaultRemarkPlugins, } = options;
|
|
122
121
|
const contentDirs = getContentPathList(contentPaths);
|
|
123
122
|
return {
|
|
@@ -169,8 +168,5 @@ async function pluginContentPages(context, options) {
|
|
|
169
168
|
};
|
|
170
169
|
}
|
|
171
170
|
exports.default = pluginContentPages;
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
return validatedOptions;
|
|
175
|
-
}
|
|
176
|
-
exports.validateOptions = validateOptions;
|
|
171
|
+
var options_1 = require("./options");
|
|
172
|
+
Object.defineProperty(exports, "validateOptions", { enumerable: true, get: function () { return options_1.validateOptions; } });
|
package/lib/options.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
import type { PluginOptions, Options } from '@docusaurus/plugin-content-pages';
|
|
8
|
+
import type { OptionValidationContext } from '@docusaurus/types';
|
|
9
|
+
export declare const DEFAULT_OPTIONS: PluginOptions;
|
|
10
|
+
export declare function validateOptions({ validate, options, }: OptionValidationContext<Options, PluginOptions>): PluginOptions;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.validateOptions = exports.DEFAULT_OPTIONS = void 0;
|
|
10
10
|
const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
11
11
|
const utils_1 = require("@docusaurus/utils");
|
|
12
12
|
exports.DEFAULT_OPTIONS = {
|
|
@@ -21,7 +21,7 @@ exports.DEFAULT_OPTIONS = {
|
|
|
21
21
|
beforeDefaultRemarkPlugins: [],
|
|
22
22
|
admonitions: {},
|
|
23
23
|
};
|
|
24
|
-
|
|
24
|
+
const PluginOptionSchema = utils_validation_1.Joi.object({
|
|
25
25
|
path: utils_validation_1.Joi.string().default(exports.DEFAULT_OPTIONS.path),
|
|
26
26
|
routeBasePath: utils_validation_1.Joi.string().default(exports.DEFAULT_OPTIONS.routeBasePath),
|
|
27
27
|
include: utils_validation_1.Joi.array().items(utils_validation_1.Joi.string()).default(exports.DEFAULT_OPTIONS.include),
|
|
@@ -33,3 +33,8 @@ exports.PluginOptionSchema = utils_validation_1.Joi.object({
|
|
|
33
33
|
beforeDefaultRemarkPlugins: utils_validation_1.RemarkPluginsSchema.default(exports.DEFAULT_OPTIONS.beforeDefaultRemarkPlugins),
|
|
34
34
|
admonitions: utils_validation_1.AdmonitionsSchema.default(exports.DEFAULT_OPTIONS.admonitions),
|
|
35
35
|
});
|
|
36
|
+
function validateOptions({ validate, options, }) {
|
|
37
|
+
const validatedOptions = validate(PluginOptionSchema, options);
|
|
38
|
+
return validatedOptions;
|
|
39
|
+
}
|
|
40
|
+
exports.validateOptions = validateOptions;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-content-pages",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-4753",
|
|
4
4
|
"description": "Pages plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/plugin-content-pages.d.ts",
|
|
@@ -18,17 +18,17 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/core": "0.0.0-
|
|
22
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
23
|
-
"@docusaurus/utils": "0.0.0-
|
|
24
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
21
|
+
"@docusaurus/core": "0.0.0-4753",
|
|
22
|
+
"@docusaurus/mdx-loader": "0.0.0-4753",
|
|
23
|
+
"@docusaurus/utils": "0.0.0-4753",
|
|
24
|
+
"@docusaurus/utils-validation": "0.0.0-4753",
|
|
25
25
|
"fs-extra": "^10.0.1",
|
|
26
26
|
"remark-admonitions": "^1.2.1",
|
|
27
27
|
"tslib": "^2.3.1",
|
|
28
28
|
"webpack": "^5.70.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@docusaurus/types": "0.0.0-
|
|
31
|
+
"@docusaurus/types": "0.0.0-4753"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"react": "^16.8.4 || ^17.0.0",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">=14"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "61ef11a14262b1821e65c45bb703698bffc891e5"
|
|
41
41
|
}
|
|
File without changes
|
package/src/index.ts
CHANGED
|
@@ -21,15 +21,9 @@ import {
|
|
|
21
21
|
DEFAULT_PLUGIN_ID,
|
|
22
22
|
parseMarkdownString,
|
|
23
23
|
} from '@docusaurus/utils';
|
|
24
|
-
import type {
|
|
25
|
-
LoadContext,
|
|
26
|
-
Plugin,
|
|
27
|
-
OptionValidationContext,
|
|
28
|
-
ValidationResult,
|
|
29
|
-
} from '@docusaurus/types';
|
|
24
|
+
import type {LoadContext, Plugin} from '@docusaurus/types';
|
|
30
25
|
import admonitions from 'remark-admonitions';
|
|
31
|
-
import {
|
|
32
|
-
import {validatePageFrontMatter} from './pageFrontMatter';
|
|
26
|
+
import {validatePageFrontMatter} from './frontMatter';
|
|
33
27
|
|
|
34
28
|
import type {LoadedContent, PagesContentPaths} from './types';
|
|
35
29
|
import type {PluginOptions, Metadata} from '@docusaurus/plugin-content-pages';
|
|
@@ -176,7 +170,7 @@ export default async function pluginContentPages(
|
|
|
176
170
|
);
|
|
177
171
|
},
|
|
178
172
|
|
|
179
|
-
configureWebpack(
|
|
173
|
+
configureWebpack(config, isServer, {getJSLoader}) {
|
|
180
174
|
const {
|
|
181
175
|
rehypePlugins,
|
|
182
176
|
remarkPlugins,
|
|
@@ -241,10 +235,4 @@ export default async function pluginContentPages(
|
|
|
241
235
|
};
|
|
242
236
|
}
|
|
243
237
|
|
|
244
|
-
export
|
|
245
|
-
validate,
|
|
246
|
-
options,
|
|
247
|
-
}: OptionValidationContext<PluginOptions>): ValidationResult<PluginOptions> {
|
|
248
|
-
const validatedOptions = validate(PluginOptionSchema, options);
|
|
249
|
-
return validatedOptions;
|
|
250
|
-
}
|
|
238
|
+
export {validateOptions} from './options';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type {PluginOptions} from '@docusaurus/plugin-content-pages';
|
|
8
|
+
import type {PluginOptions, Options} from '@docusaurus/plugin-content-pages';
|
|
9
9
|
import {
|
|
10
10
|
Joi,
|
|
11
11
|
RemarkPluginsSchema,
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
AdmonitionsSchema,
|
|
14
14
|
} from '@docusaurus/utils-validation';
|
|
15
15
|
import {GlobExcludeDefault} from '@docusaurus/utils';
|
|
16
|
+
import type {OptionValidationContext} from '@docusaurus/types';
|
|
16
17
|
|
|
17
18
|
export const DEFAULT_OPTIONS: PluginOptions = {
|
|
18
19
|
path: 'src/pages', // Path to data on filesystem, relative to site dir.
|
|
@@ -27,7 +28,7 @@ export const DEFAULT_OPTIONS: PluginOptions = {
|
|
|
27
28
|
admonitions: {},
|
|
28
29
|
};
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
const PluginOptionSchema = Joi.object({
|
|
31
32
|
path: Joi.string().default(DEFAULT_OPTIONS.path),
|
|
32
33
|
routeBasePath: Joi.string().default(DEFAULT_OPTIONS.routeBasePath),
|
|
33
34
|
include: Joi.array().items(Joi.string()).default(DEFAULT_OPTIONS.include),
|
|
@@ -43,3 +44,11 @@ export const PluginOptionSchema = Joi.object({
|
|
|
43
44
|
),
|
|
44
45
|
admonitions: AdmonitionsSchema.default(DEFAULT_OPTIONS.admonitions),
|
|
45
46
|
});
|
|
47
|
+
|
|
48
|
+
export function validateOptions({
|
|
49
|
+
validate,
|
|
50
|
+
options,
|
|
51
|
+
}: OptionValidationContext<Options, PluginOptions>): PluginOptions {
|
|
52
|
+
const validatedOptions = validate(PluginOptionSchema, options);
|
|
53
|
+
return validatedOptions;
|
|
54
|
+
}
|
|
@@ -1,10 +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
|
-
import type { PluginOptions } from '@docusaurus/plugin-content-pages';
|
|
8
|
-
import { Joi } from '@docusaurus/utils-validation';
|
|
9
|
-
export declare const DEFAULT_OPTIONS: PluginOptions;
|
|
10
|
-
export declare const PluginOptionSchema: Joi.ObjectSchema<any>;
|