@docusaurus/plugin-content-pages 2.0.0-beta.fbdeefcac → 2.0.0-rc.1
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/{src/__tests__/__fixtures__/website/i18n/fr/docusaurus-plugin-content-pages/hello/translatedJs.js → lib/frontMatter.d.ts} +4 -8
- package/lib/frontMatter.js +21 -0
- package/lib/index.d.ts +4 -3
- package/lib/index.js +45 -66
- package/lib/markdownLoader.d.ts +2 -6
- package/lib/markdownLoader.js +4 -4
- package/lib/options.d.ts +10 -0
- package/lib/{pluginOptionSchema.js → options.js} +16 -8
- package/lib/types.d.ts +0 -22
- package/package.json +14 -15
- package/src/frontMatter.ts +27 -0
- package/src/index.ts +57 -89
- package/src/markdownLoader.ts +8 -11
- package/src/{pluginOptionSchema.ts → options.ts} +15 -8
- package/src/plugin-content-pages.d.ts +59 -18
- package/src/types.ts +0 -28
- package/lib/.tsbuildinfo +0 -1
- package/lib/pluginOptionSchema.d.ts +0 -10
- package/src/__tests__/__fixtures__/website/docusaurus.config.js +0 -14
- package/src/__tests__/__fixtures__/website/i18n/fr/docusaurus-plugin-content-pages/hello/translatedMd.md +0 -1
- package/src/__tests__/__fixtures__/website/src/pages/hello/_ignore.js +0 -1
- package/src/__tests__/__fixtures__/website/src/pages/hello/_ignore.md +0 -1
- package/src/__tests__/__fixtures__/website/src/pages/hello/_ignore.mdx +0 -1
- package/src/__tests__/__fixtures__/website/src/pages/hello/_ignore.tsx +0 -1
- package/src/__tests__/__fixtures__/website/src/pages/hello/index.md +0 -2
- package/src/__tests__/__fixtures__/website/src/pages/hello/mdxPage.mdx +0 -5
- package/src/__tests__/__fixtures__/website/src/pages/hello/translatedJs.js +0 -14
- package/src/__tests__/__fixtures__/website/src/pages/hello/translatedMd.md +0 -1
- package/src/__tests__/__fixtures__/website/src/pages/hello/world.js +0 -22
- package/src/__tests__/__fixtures__/website/src/pages/index.js +0 -23
- package/src/__tests__/__fixtures__/website/src/pages/typescript.tsx +0 -22
- package/src/__tests__/index.test.ts +0 -139
- package/src/__tests__/pluginOptionSchema.test.ts +0 -54
- package/tsconfig.json +0 -9
- package/types.d.ts +0 -13
|
@@ -4,11 +4,7 @@
|
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
render() {
|
|
12
|
-
return <div>TranslatedJsPage (fr)</div>;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
7
|
+
import type { FrontMatter } from '@docusaurus/plugin-content-pages';
|
|
8
|
+
export declare function validatePageFrontMatter(frontMatter: {
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}): FrontMatter;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.validatePageFrontMatter = void 0;
|
|
10
|
+
const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
11
|
+
const PageFrontMatterSchema = utils_validation_1.Joi.object({
|
|
12
|
+
title: utils_validation_1.Joi.string(),
|
|
13
|
+
description: utils_validation_1.Joi.string(),
|
|
14
|
+
wrapperClassName: utils_validation_1.Joi.string(),
|
|
15
|
+
hide_table_of_contents: utils_validation_1.Joi.boolean(),
|
|
16
|
+
...utils_validation_1.FrontMatterTOCHeadingLevels,
|
|
17
|
+
});
|
|
18
|
+
function validatePageFrontMatter(frontMatter) {
|
|
19
|
+
return (0, utils_validation_1.validateFrontMatter)(frontMatter, PageFrontMatterSchema);
|
|
20
|
+
}
|
|
21
|
+
exports.validatePageFrontMatter = validatePageFrontMatter;
|
package/lib/index.d.ts
CHANGED
|
@@ -4,8 +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 { LoadContext, Plugin
|
|
8
|
-
import {
|
|
7
|
+
import type { LoadContext, Plugin } from '@docusaurus/types';
|
|
8
|
+
import type { PagesContentPaths } from './types';
|
|
9
|
+
import type { PluginOptions, LoadedContent } from '@docusaurus/plugin-content-pages';
|
|
9
10
|
export declare function getContentPathList(contentPaths: PagesContentPaths): string[];
|
|
10
11
|
export default function pluginContentPages(context: LoadContext, options: PluginOptions): Plugin<LoadedContent | null>;
|
|
11
|
-
export
|
|
12
|
+
export { validateOptions } from './options';
|
package/lib/index.js
CHANGED
|
@@ -8,89 +8,71 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.validateOptions = exports.getContentPathList = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
|
-
const
|
|
12
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
11
|
+
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
13
12
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
14
|
-
const minimatch_1 = tslib_1.__importDefault(require("minimatch"));
|
|
15
|
-
const slash_1 = tslib_1.__importDefault(require("slash"));
|
|
16
13
|
const utils_1 = require("@docusaurus/utils");
|
|
17
|
-
const
|
|
18
|
-
const pluginOptionSchema_1 = require("./pluginOptionSchema");
|
|
19
|
-
const constants_1 = require("@docusaurus/core/lib/constants");
|
|
20
|
-
const lodash_1 = require("lodash");
|
|
14
|
+
const frontMatter_1 = require("./frontMatter");
|
|
21
15
|
function getContentPathList(contentPaths) {
|
|
22
16
|
return [contentPaths.contentPathLocalized, contentPaths.contentPath];
|
|
23
17
|
}
|
|
24
18
|
exports.getContentPathList = getContentPathList;
|
|
25
19
|
const isMarkdownSource = (source) => source.endsWith('.md') || source.endsWith('.mdx');
|
|
26
20
|
function pluginContentPages(context, options) {
|
|
27
|
-
|
|
28
|
-
if (options.admonitions) {
|
|
29
|
-
options.remarkPlugins = options.remarkPlugins.concat([
|
|
30
|
-
[remark_admonitions_1.default, options.admonitions || {}],
|
|
31
|
-
]);
|
|
32
|
-
}
|
|
33
|
-
const { siteConfig, siteDir, generatedFilesDir, i18n: { currentLocale }, } = context;
|
|
21
|
+
const { siteConfig, siteDir, generatedFilesDir, localizationDir } = context;
|
|
34
22
|
const contentPaths = {
|
|
35
23
|
contentPath: path_1.default.resolve(siteDir, options.path),
|
|
36
|
-
contentPathLocalized: utils_1.getPluginI18nPath({
|
|
37
|
-
|
|
38
|
-
locale: currentLocale,
|
|
24
|
+
contentPathLocalized: (0, utils_1.getPluginI18nPath)({
|
|
25
|
+
localizationDir,
|
|
39
26
|
pluginName: 'docusaurus-plugin-content-pages',
|
|
40
27
|
pluginId: options.id,
|
|
41
28
|
}),
|
|
42
29
|
};
|
|
43
30
|
const pluginDataDirRoot = path_1.default.join(generatedFilesDir, 'docusaurus-plugin-content-pages');
|
|
44
|
-
const dataDir = path_1.default.join(pluginDataDirRoot,
|
|
45
|
-
const excludeRegex = new RegExp(options.exclude
|
|
46
|
-
.map((pattern) => minimatch_1.default.makeRe(pattern).source)
|
|
47
|
-
.join('|'));
|
|
31
|
+
const dataDir = path_1.default.join(pluginDataDirRoot, options.id ?? utils_1.DEFAULT_PLUGIN_ID);
|
|
48
32
|
return {
|
|
49
33
|
name: 'docusaurus-plugin-content-pages',
|
|
50
34
|
getPathsToWatch() {
|
|
51
|
-
const { include
|
|
52
|
-
return
|
|
53
|
-
return include.map((pattern) => `${contentPath}/${pattern}`);
|
|
54
|
-
}));
|
|
55
|
-
},
|
|
56
|
-
getClientModules() {
|
|
57
|
-
const modules = [];
|
|
58
|
-
if (options.admonitions) {
|
|
59
|
-
modules.push(require.resolve('remark-admonitions/styles/infima.css'));
|
|
60
|
-
}
|
|
61
|
-
return modules;
|
|
35
|
+
const { include } = options;
|
|
36
|
+
return getContentPathList(contentPaths).flatMap((contentPath) => include.map((pattern) => `${contentPath}/${pattern}`));
|
|
62
37
|
},
|
|
63
38
|
async loadContent() {
|
|
64
39
|
const { include } = options;
|
|
65
|
-
if (!
|
|
40
|
+
if (!(await fs_extra_1.default.pathExists(contentPaths.contentPath))) {
|
|
66
41
|
return null;
|
|
67
42
|
}
|
|
68
43
|
const { baseUrl } = siteConfig;
|
|
69
|
-
const pagesFiles = await
|
|
44
|
+
const pagesFiles = await (0, utils_1.Globby)(include, {
|
|
70
45
|
cwd: contentPaths.contentPath,
|
|
71
46
|
ignore: options.exclude,
|
|
72
47
|
});
|
|
73
48
|
async function toMetadata(relativeSource) {
|
|
74
49
|
// Lookup in localized folder in priority
|
|
75
|
-
const contentPath = await utils_1.getFolderContainingFile(getContentPathList(contentPaths), relativeSource);
|
|
50
|
+
const contentPath = await (0, utils_1.getFolderContainingFile)(getContentPathList(contentPaths), relativeSource);
|
|
76
51
|
const source = path_1.default.join(contentPath, relativeSource);
|
|
77
|
-
const aliasedSourcePath = utils_1.aliasedSitePath(source, siteDir);
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
source: aliasedSourcePath,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
52
|
+
const aliasedSourcePath = (0, utils_1.aliasedSitePath)(source, siteDir);
|
|
53
|
+
const permalink = (0, utils_1.normalizeUrl)([
|
|
54
|
+
baseUrl,
|
|
55
|
+
options.routeBasePath,
|
|
56
|
+
(0, utils_1.encodePath)((0, utils_1.fileToPath)(relativeSource)),
|
|
57
|
+
]);
|
|
58
|
+
if (!isMarkdownSource(relativeSource)) {
|
|
88
59
|
return {
|
|
89
60
|
type: 'jsx',
|
|
90
61
|
permalink,
|
|
91
62
|
source: aliasedSourcePath,
|
|
92
63
|
};
|
|
93
64
|
}
|
|
65
|
+
const content = await fs_extra_1.default.readFile(source, 'utf-8');
|
|
66
|
+
const { frontMatter: unsafeFrontMatter, contentTitle, excerpt, } = (0, utils_1.parseMarkdownString)(content);
|
|
67
|
+
const frontMatter = (0, frontMatter_1.validatePageFrontMatter)(unsafeFrontMatter);
|
|
68
|
+
return {
|
|
69
|
+
type: 'mdx',
|
|
70
|
+
permalink,
|
|
71
|
+
source: aliasedSourcePath,
|
|
72
|
+
title: frontMatter.title ?? contentTitle,
|
|
73
|
+
description: frontMatter.description ?? excerpt,
|
|
74
|
+
frontMatter,
|
|
75
|
+
};
|
|
94
76
|
}
|
|
95
77
|
return Promise.all(pagesFiles.map(toMetadata));
|
|
96
78
|
},
|
|
@@ -105,7 +87,7 @@ function pluginContentPages(context, options) {
|
|
|
105
87
|
await createData(
|
|
106
88
|
// Note that this created data path must be in sync with
|
|
107
89
|
// metadataPath provided to mdx-loader.
|
|
108
|
-
`${utils_1.docuHash(metadata.source)}.json`, JSON.stringify(metadata, null, 2));
|
|
90
|
+
`${(0, utils_1.docuHash)(metadata.source)}.json`, JSON.stringify(metadata, null, 2));
|
|
109
91
|
addRoute({
|
|
110
92
|
path: permalink,
|
|
111
93
|
component: options.mdxPageComponent,
|
|
@@ -127,8 +109,9 @@ function pluginContentPages(context, options) {
|
|
|
127
109
|
}
|
|
128
110
|
}));
|
|
129
111
|
},
|
|
130
|
-
configureWebpack(
|
|
131
|
-
const { rehypePlugins, remarkPlugins, beforeDefaultRehypePlugins, beforeDefaultRemarkPlugins, } = options;
|
|
112
|
+
configureWebpack(config, isServer, { getJSLoader }) {
|
|
113
|
+
const { admonitions, rehypePlugins, remarkPlugins, beforeDefaultRehypePlugins, beforeDefaultRemarkPlugins, } = options;
|
|
114
|
+
const contentDirs = getContentPathList(contentPaths);
|
|
132
115
|
return {
|
|
133
116
|
resolve: {
|
|
134
117
|
alias: {
|
|
@@ -138,8 +121,8 @@ function pluginContentPages(context, options) {
|
|
|
138
121
|
module: {
|
|
139
122
|
rules: [
|
|
140
123
|
{
|
|
141
|
-
test:
|
|
142
|
-
include:
|
|
124
|
+
test: /\.mdx?$/i,
|
|
125
|
+
include: contentDirs
|
|
143
126
|
// Trailing slash is important, see https://github.com/facebook/docusaurus/pull/3970
|
|
144
127
|
.map(utils_1.addTrailingPathSeparator),
|
|
145
128
|
use: [
|
|
@@ -147,21 +130,20 @@ function pluginContentPages(context, options) {
|
|
|
147
130
|
{
|
|
148
131
|
loader: require.resolve('@docusaurus/mdx-loader'),
|
|
149
132
|
options: {
|
|
133
|
+
admonitions,
|
|
150
134
|
remarkPlugins,
|
|
151
135
|
rehypePlugins,
|
|
152
136
|
beforeDefaultRehypePlugins,
|
|
153
137
|
beforeDefaultRemarkPlugins,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
138
|
+
staticDirs: siteConfig.staticDirectories.map((dir) => path_1.default.resolve(siteDir, dir)),
|
|
139
|
+
siteDir,
|
|
140
|
+
isMDXPartial: (0, utils_1.createAbsoluteFilePathMatcher)(options.exclude, contentDirs),
|
|
157
141
|
metadataPath: (mdxPath) => {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
return path_1.default.join(dataDir, `${utils_1.docuHash(aliasedSource)}.json`);
|
|
142
|
+
// Note that metadataPath must be the same/in-sync as
|
|
143
|
+
// the path from createData for each MDX.
|
|
144
|
+
const aliasedSource = (0, utils_1.aliasedSitePath)(mdxPath, siteDir);
|
|
145
|
+
return path_1.default.join(dataDir, `${(0, utils_1.docuHash)(aliasedSource)}.json`);
|
|
163
146
|
},
|
|
164
|
-
forbidFrontMatter: (mdxPath) => excludeRegex.test(slash_1.default(mdxPath)),
|
|
165
147
|
},
|
|
166
148
|
},
|
|
167
149
|
{
|
|
@@ -180,8 +162,5 @@ function pluginContentPages(context, options) {
|
|
|
180
162
|
};
|
|
181
163
|
}
|
|
182
164
|
exports.default = pluginContentPages;
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
return validatedOptions;
|
|
186
|
-
}
|
|
187
|
-
exports.validateOptions = validateOptions;
|
|
165
|
+
var options_1 = require("./options");
|
|
166
|
+
Object.defineProperty(exports, "validateOptions", { enumerable: true, get: function () { return options_1.validateOptions; } });
|
package/lib/markdownLoader.d.ts
CHANGED
|
@@ -4,9 +4,5 @@
|
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
(this: any, source: string): string | Buffer | void | undefined;
|
|
10
|
-
}
|
|
11
|
-
declare const markdownLoader: Loader;
|
|
12
|
-
export default markdownLoader;
|
|
7
|
+
import type { LoaderContext } from 'webpack';
|
|
8
|
+
export default function markdownLoader(this: LoaderContext<undefined>, fileString: string): void;
|
package/lib/markdownLoader.js
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
|
|
9
|
+
function markdownLoader(fileString) {
|
|
10
10
|
const callback = this.async();
|
|
11
11
|
// const options = this.getOptions();
|
|
12
|
-
// TODO provide
|
|
12
|
+
// TODO provide additional md processing here? like interlinking pages?
|
|
13
13
|
// fileString = linkify(fileString)
|
|
14
|
-
return callback
|
|
15
|
-
}
|
|
14
|
+
return callback(null, fileString);
|
|
15
|
+
}
|
|
16
16
|
exports.default = markdownLoader;
|
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 { OptionValidationContext } from '@docusaurus/types';
|
|
8
|
+
import type { PluginOptions, Options } from '@docusaurus/plugin-content-pages';
|
|
9
|
+
export declare const DEFAULT_OPTIONS: PluginOptions;
|
|
10
|
+
export declare function validateOptions({ validate, options, }: OptionValidationContext<Options, PluginOptions>): PluginOptions;
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
9
|
+
exports.validateOptions = exports.DEFAULT_OPTIONS = void 0;
|
|
4
10
|
const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
11
|
+
const utils_1 = require("@docusaurus/utils");
|
|
5
12
|
exports.DEFAULT_OPTIONS = {
|
|
6
13
|
path: 'src/pages',
|
|
7
14
|
routeBasePath: '/',
|
|
8
15
|
include: ['**/*.{js,jsx,ts,tsx,md,mdx}'],
|
|
16
|
+
exclude: utils_1.GlobExcludeDefault,
|
|
9
17
|
mdxPageComponent: '@theme/MDXPage',
|
|
10
18
|
remarkPlugins: [],
|
|
11
19
|
rehypePlugins: [],
|
|
12
20
|
beforeDefaultRehypePlugins: [],
|
|
13
21
|
beforeDefaultRemarkPlugins: [],
|
|
14
|
-
admonitions:
|
|
15
|
-
exclude: [
|
|
16
|
-
'**/_*.{js,jsx,ts,tsx,md,mdx}',
|
|
17
|
-
'**/*.test.{js,ts}',
|
|
18
|
-
'**/__tests__/**',
|
|
19
|
-
],
|
|
22
|
+
admonitions: true,
|
|
20
23
|
};
|
|
21
|
-
|
|
24
|
+
const PluginOptionSchema = utils_validation_1.Joi.object({
|
|
22
25
|
path: utils_validation_1.Joi.string().default(exports.DEFAULT_OPTIONS.path),
|
|
23
26
|
routeBasePath: utils_validation_1.Joi.string().default(exports.DEFAULT_OPTIONS.routeBasePath),
|
|
24
27
|
include: utils_validation_1.Joi.array().items(utils_validation_1.Joi.string()).default(exports.DEFAULT_OPTIONS.include),
|
|
@@ -30,3 +33,8 @@ exports.PluginOptionSchema = utils_validation_1.Joi.object({
|
|
|
30
33
|
beforeDefaultRemarkPlugins: utils_validation_1.RemarkPluginsSchema.default(exports.DEFAULT_OPTIONS.beforeDefaultRemarkPlugins),
|
|
31
34
|
admonitions: utils_validation_1.AdmonitionsSchema.default(exports.DEFAULT_OPTIONS.admonitions),
|
|
32
35
|
});
|
|
36
|
+
function validateOptions({ validate, options, }) {
|
|
37
|
+
const validatedOptions = validate(PluginOptionSchema, options);
|
|
38
|
+
return validatedOptions;
|
|
39
|
+
}
|
|
40
|
+
exports.validateOptions = validateOptions;
|
package/lib/types.d.ts
CHANGED
|
@@ -4,28 +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
|
-
import type { RemarkAndRehypePluginOptions } from '@docusaurus/mdx-loader';
|
|
8
|
-
export interface PluginOptions extends RemarkAndRehypePluginOptions {
|
|
9
|
-
id?: string;
|
|
10
|
-
path: string;
|
|
11
|
-
routeBasePath: string;
|
|
12
|
-
include: string[];
|
|
13
|
-
exclude: string[];
|
|
14
|
-
mdxPageComponent: string;
|
|
15
|
-
admonitions: Record<string, unknown>;
|
|
16
|
-
}
|
|
17
|
-
export declare type JSXPageMetadata = {
|
|
18
|
-
type: 'jsx';
|
|
19
|
-
permalink: string;
|
|
20
|
-
source: string;
|
|
21
|
-
};
|
|
22
|
-
export declare type MDXPageMetadata = {
|
|
23
|
-
type: 'mdx';
|
|
24
|
-
permalink: string;
|
|
25
|
-
source: string;
|
|
26
|
-
};
|
|
27
|
-
export declare type Metadata = JSXPageMetadata | MDXPageMetadata;
|
|
28
|
-
export declare type LoadedContent = Metadata[];
|
|
29
7
|
export declare type PagesContentPaths = {
|
|
30
8
|
contentPath: string;
|
|
31
9
|
contentPathLocalized: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-content-pages",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-rc.1",
|
|
4
4
|
"description": "Pages plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/plugin-content-pages.d.ts",
|
|
@@ -18,25 +18,24 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/core": "2.0.0-
|
|
22
|
-
"@docusaurus/mdx-loader": "2.0.0-
|
|
23
|
-
"@docusaurus/types": "2.0.0-
|
|
24
|
-
"@docusaurus/utils": "2.0.0-
|
|
25
|
-
"@docusaurus/utils-validation": "2.0.0-
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
"webpack": "^5.40.0"
|
|
21
|
+
"@docusaurus/core": "2.0.0-rc.1",
|
|
22
|
+
"@docusaurus/mdx-loader": "2.0.0-rc.1",
|
|
23
|
+
"@docusaurus/types": "2.0.0-rc.1",
|
|
24
|
+
"@docusaurus/utils": "2.0.0-rc.1",
|
|
25
|
+
"@docusaurus/utils-validation": "2.0.0-rc.1",
|
|
26
|
+
"fs-extra": "^10.1.0",
|
|
27
|
+
"tslib": "^2.4.0",
|
|
28
|
+
"webpack": "^5.73.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@docusaurus/types": "2.0.0-beta.21"
|
|
33
32
|
},
|
|
34
33
|
"peerDependencies": {
|
|
35
34
|
"react": "^16.8.4 || ^17.0.0",
|
|
36
35
|
"react-dom": "^16.8.4 || ^17.0.0"
|
|
37
36
|
},
|
|
38
37
|
"engines": {
|
|
39
|
-
"node": ">=
|
|
38
|
+
"node": ">=16.14"
|
|
40
39
|
},
|
|
41
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "c8ddd02a8e68dfaf515c20465a049a83153bd205"
|
|
42
41
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
import {
|
|
9
|
+
Joi,
|
|
10
|
+
validateFrontMatter,
|
|
11
|
+
FrontMatterTOCHeadingLevels,
|
|
12
|
+
} from '@docusaurus/utils-validation';
|
|
13
|
+
import type {FrontMatter} from '@docusaurus/plugin-content-pages';
|
|
14
|
+
|
|
15
|
+
const PageFrontMatterSchema = Joi.object<FrontMatter>({
|
|
16
|
+
title: Joi.string(),
|
|
17
|
+
description: Joi.string(),
|
|
18
|
+
wrapperClassName: Joi.string(),
|
|
19
|
+
hide_table_of_contents: Joi.boolean(),
|
|
20
|
+
...FrontMatterTOCHeadingLevels,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export function validatePageFrontMatter(frontMatter: {
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
}): FrontMatter {
|
|
26
|
+
return validateFrontMatter(frontMatter, PageFrontMatterSchema);
|
|
27
|
+
}
|