@docusaurus/plugin-content-pages 2.0.0-beta.17 → 2.0.0-beta.18

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.
@@ -5,4 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { FrontMatter } from '@docusaurus/plugin-content-pages';
8
- export declare function validatePageFrontMatter(frontMatter: Record<string, unknown>): FrontMatter;
8
+ export declare function validatePageFrontMatter(frontMatter: {
9
+ [key: string]: unknown;
10
+ }): FrontMatter;
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, OptionValidationContext, ValidationResult } from '@docusaurus/types';
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 declare function validateOptions({ validate, options, }: OptionValidationContext<PluginOptions>): ValidationResult<PluginOptions>;
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 pluginOptionSchema_1 = require("./pluginOptionSchema");
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
  }
@@ -22,7 +21,7 @@ const isMarkdownSource = (source) => source.endsWith('.md') || source.endsWith('
22
21
  async function pluginContentPages(context, options) {
23
22
  if (options.admonitions) {
24
23
  options.remarkPlugins = options.remarkPlugins.concat([
25
- [remark_admonitions_1.default, options.admonitions || {}],
24
+ [remark_admonitions_1.default, options.admonitions],
26
25
  ]);
27
26
  }
28
27
  const { siteConfig, siteDir, generatedFilesDir, i18n: { currentLocale }, } = context;
@@ -40,7 +39,7 @@ async function pluginContentPages(context, options) {
40
39
  return {
41
40
  name: 'docusaurus-plugin-content-pages',
42
41
  getPathsToWatch() {
43
- const { include = [] } = options;
42
+ const { include } = options;
44
43
  return getContentPathList(contentPaths).flatMap((contentPath) => include.map((pattern) => `${contentPath}/${pattern}`));
45
44
  },
46
45
  async loadContent() {
@@ -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, pageFrontMatter_1.validatePageFrontMatter)(unsafeFrontMatter);
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(_config, isServer, { getJSLoader }) {
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
- function validateOptions({ validate, options, }) {
173
- const validatedOptions = validate(pluginOptionSchema_1.PluginOptionSchema, options);
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; } });
@@ -11,6 +11,6 @@ function markdownLoader(fileString) {
11
11
  // const options = this.getOptions();
12
12
  // TODO provide additional md processing here? like interlinking pages?
13
13
  // fileString = linkify(fileString)
14
- return callback && callback(null, fileString);
14
+ return callback?.(null, fileString);
15
15
  }
16
16
  exports.default = markdownLoader;
@@ -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.PluginOptionSchema = exports.DEFAULT_OPTIONS = void 0;
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
- exports.PluginOptionSchema = utils_validation_1.Joi.object({
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": "2.0.0-beta.17",
3
+ "version": "2.0.0-beta.18",
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": "2.0.0-beta.17",
22
- "@docusaurus/mdx-loader": "2.0.0-beta.17",
23
- "@docusaurus/utils": "2.0.0-beta.17",
24
- "@docusaurus/utils-validation": "2.0.0-beta.17",
21
+ "@docusaurus/core": "2.0.0-beta.18",
22
+ "@docusaurus/mdx-loader": "2.0.0-beta.18",
23
+ "@docusaurus/utils": "2.0.0-beta.18",
24
+ "@docusaurus/utils-validation": "2.0.0-beta.18",
25
25
  "fs-extra": "^10.0.1",
26
26
  "remark-admonitions": "^1.2.1",
27
27
  "tslib": "^2.3.1",
28
- "webpack": "^5.69.1"
28
+ "webpack": "^5.70.0"
29
29
  },
30
30
  "devDependencies": {
31
- "@docusaurus/types": "2.0.0-beta.17"
31
+ "@docusaurus/types": "2.0.0-beta.18"
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": "0032c0b0480083227af2e1b4da2d3ee6ce992403"
40
+ "gitHead": "1a945d06993d53376e61bed2c942799fe07dc336"
41
41
  }
package/src/deps.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  declare module 'remark-admonitions' {
9
- type Options = Record<string, unknown>;
9
+ type Options = {[key: string]: unknown};
10
10
 
11
11
  const plugin: (options?: Options) => void;
12
12
  export = plugin;
@@ -20,8 +20,8 @@ const PageFrontMatterSchema = Joi.object<FrontMatter>({
20
20
  ...FrontMatterTOCHeadingLevels,
21
21
  });
22
22
 
23
- export function validatePageFrontMatter(
24
- frontMatter: Record<string, unknown>,
25
- ): FrontMatter {
23
+ export function validatePageFrontMatter(frontMatter: {
24
+ [key: string]: unknown;
25
+ }): FrontMatter {
26
26
  return validateFrontMatter(frontMatter, PageFrontMatterSchema);
27
27
  }
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 {PluginOptionSchema} from './pluginOptionSchema';
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';
@@ -47,7 +41,7 @@ export default async function pluginContentPages(
47
41
  ): Promise<Plugin<LoadedContent | null>> {
48
42
  if (options.admonitions) {
49
43
  options.remarkPlugins = options.remarkPlugins.concat([
50
- [admonitions, options.admonitions || {}],
44
+ [admonitions, options.admonitions],
51
45
  ]);
52
46
  }
53
47
  const {
@@ -77,7 +71,7 @@ export default async function pluginContentPages(
77
71
  name: 'docusaurus-plugin-content-pages',
78
72
 
79
73
  getPathsToWatch() {
80
- const {include = []} = options;
74
+ const {include} = options;
81
75
  return getContentPathList(contentPaths).flatMap((contentPath) =>
82
76
  include.map((pattern) => `${contentPath}/${pattern}`),
83
77
  );
@@ -176,7 +170,7 @@ export default async function pluginContentPages(
176
170
  );
177
171
  },
178
172
 
179
- configureWebpack(_config, isServer, {getJSLoader}) {
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 function validateOptions({
245
- validate,
246
- options,
247
- }: OptionValidationContext<PluginOptions>): ValidationResult<PluginOptions> {
248
- const validatedOptions = validate(PluginOptionSchema, options);
249
- return validatedOptions;
250
- }
238
+ export {validateOptions} from './options';
@@ -18,5 +18,5 @@ export default function markdownLoader(
18
18
  // TODO provide additional md processing here? like interlinking pages?
19
19
  // fileString = linkify(fileString)
20
20
 
21
- return callback && callback(null, fileString);
21
+ return callback?.(null, fileString);
22
22
  }
@@ -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
- export const PluginOptionSchema = Joi.object({
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
+ }
@@ -15,7 +15,7 @@ declare module '@docusaurus/plugin-content-pages' {
15
15
  include: string[];
16
16
  exclude: string[];
17
17
  mdxPageComponent: string;
18
- admonitions: Record<string, unknown>;
18
+ admonitions: {[key: string]: unknown};
19
19
  };
20
20
 
21
21
  export type Options = Partial<PluginOptions>;
@@ -39,7 +39,7 @@ declare module '@docusaurus/plugin-content-pages' {
39
39
  type: 'mdx';
40
40
  permalink: string;
41
41
  source: string;
42
- frontMatter: FrontMatter & Record<string, unknown>;
42
+ frontMatter: FrontMatter & {[key: string]: unknown};
43
43
  title?: string;
44
44
  description?: string;
45
45
  };
@@ -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>;