@docusaurus/mdx-loader 0.0.0-4816 → 0.0.0-4819

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/index.js CHANGED
@@ -139,9 +139,9 @@ async function mdxLoader(fileString) {
139
139
  // Partial are not expected to have associated metadata files or front matter
140
140
  const isMDXPartial = options.isMDXPartial?.(filePath);
141
141
  if (isMDXPartial && hasFrontMatter) {
142
- const errorMessage = `Docusaurus MDX partial files should not contain FrontMatter.
142
+ const errorMessage = `Docusaurus MDX partial files should not contain front matter.
143
143
  Those partial files use the _ prefix as a convention by default, but this is configurable.
144
- File at ${filePath} contains FrontMatter that will be ignored:
144
+ File at ${filePath} contains front matter that will be ignored:
145
145
  ${JSON.stringify(frontMatter, null, 2)}`;
146
146
  if (!options.isMDXPartialFrontMatterWarningDisabled) {
147
147
  const shouldError = process.env.NODE_ENV === 'test' || process.env.CI;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/headings/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAIzC,MAAM,CAAC,OAAO,UAAU,MAAM,IAAI,WAAW,CAwD5C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/headings/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAGzC,MAAM,CAAC,OAAO,UAAU,MAAM,IAAI,WAAW,CAsD5C"}
@@ -23,9 +23,7 @@ function plugin() {
23
23
  }
24
24
  else {
25
25
  const headingTextNodes = headingNode.children.filter(({ type }) => !['html', 'jsx'].includes(type));
26
- const heading = (0, mdast_util_to_string_1.default)(headingTextNodes.length > 0
27
- ? { children: headingTextNodes }
28
- : headingNode);
26
+ const heading = (0, mdast_util_to_string_1.default)(headingTextNodes.length > 0 ? headingTextNodes : headingNode);
29
27
  // Support explicit heading IDs
30
28
  const parsedHeading = (0, utils_1.parseMarkdownHeadingId)(heading);
31
29
  id = parsedHeading.id || slugs.slug(heading);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/headings/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,gMAAgM;AAEhM,6CAAwE;AACxE,gFAAqC;AACrC,wFAA4C;AAK5C,SAAwB,MAAM;IAC5B,OAAO,CAAC,IAAI,EAAE,EAAE;QACd,MAAM,KAAK,GAAG,IAAA,qBAAa,GAAE,CAAC;QAC9B,IAAA,0BAAK,EAAC,IAAI,EAAE,SAAS,EAAE,CAAC,WAAoB,EAAE,EAAE;YAC9C,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;YACzD,MAAM,UAAU,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC,CAE9D,CAAC;YACF,IAAI,EAAC,EAAE,EAAC,GAAG,UAAU,CAAC;YAEtB,IAAI,EAAE,EAAE;gBACN,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,EAAC,YAAY,EAAE,IAAI,EAAC,CAAC,CAAC;aAC3C;iBAAM;gBACL,MAAM,gBAAgB,GAAG,WAAW,CAAC,QAAQ,CAAC,MAAM,CAClD,CAAC,EAAC,IAAI,EAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAC5C,CAAC;gBACF,MAAM,OAAO,GAAG,IAAA,8BAAQ,EACtB,gBAAgB,CAAC,MAAM,GAAG,CAAC;oBACzB,CAAC,CAAE,EAAC,QAAQ,EAAE,gBAAgB,EAAY;oBAC1C,CAAC,CAAC,WAAW,CAChB,CAAC;gBAEF,+BAA+B;gBAC/B,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,CAAC,CAAC,IAAI,CAAC;wBACjE,iDAAiD;wBACjD,IAAI,YAAY,EAAE;4BAChB,QAAQ,CAAC,KAAK,GAAG,YAAY,CAAC;yBAC/B;wBACD,mEAAmE;6BAC9D;4BACH,WAAW,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;yBAC5B;qBACF;yBAAM;wBACL,QAAQ,CAAC,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC;qBACrC;iBACF;aACF;YAED,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;YACb,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;QACrB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAtDD,yBAsDC"}
@@ -5,9 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { Transformer } from 'unified';
8
- interface PluginOptions {
8
+ declare type PluginOptions = {
9
9
  name?: string;
10
- }
10
+ };
11
11
  export default function plugin(options?: PluginOptions): Transformer;
12
12
  export {};
13
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/toc/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAWzC,UAAU,aAAa;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAyCD,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,OAAO,GAAE,aAAkB,GAAG,WAAW,CA6BvE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/toc/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAWzC,aAAK,aAAa,GAAG;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAyCF,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,OAAO,GAAE,aAAkB,GAAG,WAAW,CA6BvE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/mdx-loader",
3
- "version": "0.0.0-4816",
3
+ "version": "0.0.0-4819",
4
4
  "description": "Docusaurus Loader for MDX",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/mdx-loader.d.ts",
@@ -20,8 +20,8 @@
20
20
  "dependencies": {
21
21
  "@babel/parser": "^7.17.8",
22
22
  "@babel/traverse": "^7.17.3",
23
- "@docusaurus/logger": "0.0.0-4816",
24
- "@docusaurus/utils": "0.0.0-4816",
23
+ "@docusaurus/logger": "0.0.0-4819",
24
+ "@docusaurus/utils": "0.0.0-4819",
25
25
  "@mdx-js/mdx": "^1.6.22",
26
26
  "escape-html": "^1.0.3",
27
27
  "file-loader": "^6.2.0",
@@ -36,7 +36,7 @@
36
36
  "webpack": "^5.70.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@docusaurus/types": "0.0.0-4816",
39
+ "@docusaurus/types": "0.0.0-4819",
40
40
  "@types/escape-html": "^1.0.1",
41
41
  "@types/mdast": "^3.0.10",
42
42
  "@types/stringify-object": "^3.3.1",
@@ -54,5 +54,5 @@
54
54
  "engines": {
55
55
  "node": ">=14"
56
56
  },
57
- "gitHead": "d5a8e65a97b9895a6cda1b858ea40a534e8a2483"
57
+ "gitHead": "f91fc42f44d6a94159c7d777ca5a776b1c623110"
58
58
  }
package/src/deps.d.ts CHANGED
@@ -10,13 +10,13 @@ declare module '@mdx-js/mdx' {
10
10
  import type {Processor} from 'unified';
11
11
  import type {RemarkOrRehypePlugin} from '@docusaurus/mdx-loader';
12
12
 
13
- export interface Options {
13
+ export type Options = {
14
14
  filepath?: string;
15
15
  skipExport?: boolean;
16
16
  wrapExport?: string;
17
17
  remarkPlugins?: RemarkOrRehypePlugin[];
18
18
  rehypePlugins?: RemarkOrRehypePlugin[];
19
- }
19
+ };
20
20
 
21
21
  export function sync(content: string, options?: Options): string;
22
22
  export function createMdxAstCompiler(options?: Options): Processor;
package/src/index.ts CHANGED
@@ -182,9 +182,9 @@ export default async function mdxLoader(
182
182
  // Partial are not expected to have associated metadata files or front matter
183
183
  const isMDXPartial = options.isMDXPartial?.(filePath);
184
184
  if (isMDXPartial && hasFrontMatter) {
185
- const errorMessage = `Docusaurus MDX partial files should not contain FrontMatter.
185
+ const errorMessage = `Docusaurus MDX partial files should not contain front matter.
186
186
  Those partial files use the _ prefix as a convention by default, but this is configurable.
187
- File at ${filePath} contains FrontMatter that will be ignored:
187
+ File at ${filePath} contains front matter that will be ignored:
188
188
  ${JSON.stringify(frontMatter, null, 2)}`;
189
189
 
190
190
  if (!options.isMDXPartialFrontMatterWarningDisabled) {
@@ -9,9 +9,8 @@
9
9
 
10
10
  import {parseMarkdownHeadingId, createSlugger} from '@docusaurus/utils';
11
11
  import visit from 'unist-util-visit';
12
- import toString from 'mdast-util-to-string';
12
+ import mdastToString from 'mdast-util-to-string';
13
13
  import type {Transformer} from 'unified';
14
- import type {Parent} from 'unist';
15
14
  import type {Heading, Text} from 'mdast';
16
15
 
17
16
  export default function plugin(): Transformer {
@@ -30,10 +29,8 @@ export default function plugin(): Transformer {
30
29
  const headingTextNodes = headingNode.children.filter(
31
30
  ({type}) => !['html', 'jsx'].includes(type),
32
31
  );
33
- const heading = toString(
34
- headingTextNodes.length > 0
35
- ? ({children: headingTextNodes} as Parent)
36
- : headingNode,
32
+ const heading = mdastToString(
33
+ headingTextNodes.length > 0 ? headingTextNodes : headingNode,
37
34
  );
38
35
 
39
36
  // Support explicit heading IDs
@@ -27,9 +27,9 @@ const isImport = (child: Node): child is Literal => child.type === 'import';
27
27
  const hasImports = (index: number) => index > -1;
28
28
  const isExport = (child: Node): child is Literal => child.type === 'export';
29
29
 
30
- interface PluginOptions {
30
+ type PluginOptions = {
31
31
  name?: string;
32
- }
32
+ };
33
33
 
34
34
  const isTarget = (child: Literal, name: string) => {
35
35
  let found = false;