@docusaurus/mdx-loader 0.0.0-5878 → 0.0.0-5880

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/contentTitle/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,KAAK,MAAM,GAAG,GAAG,CAAC;AAMlB;;;;GAIG;AACH,QAAA,MAAM,MAAM,EAAE,MA0Bb,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/contentTitle/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,KAAK,MAAM,GAAG,GAAG,CAAC;AAMlB;;;;GAIG;AACH,QAAA,MAAM,MAAM,EAAE,MAiCb,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -17,17 +17,24 @@ const plugin = function plugin(options = {}) {
17
17
  return async (root, vfile) => {
18
18
  const { toString } = await import('mdast-util-to-string');
19
19
  const { visit, EXIT } = await import('unist-util-visit');
20
- visit(root, 'heading', (headingNode, index, parent) => {
21
- if (headingNode.depth === 1) {
22
- vfile.data.contentTitle = toString(headingNode);
23
- if (removeContentTitle) {
24
- // @ts-expect-error: TODO how to fix?
25
- parent.children.splice(index, 1);
20
+ visit(root, ['heading', 'thematicBreak'], (node, index, parent) => {
21
+ if (node.type === 'heading') {
22
+ const headingNode = node;
23
+ if (headingNode.depth === 1) {
24
+ vfile.data.contentTitle = toString(headingNode);
25
+ if (removeContentTitle) {
26
+ // @ts-expect-error: TODO how to fix?
27
+ parent.children.splice(index, 1);
28
+ }
29
+ return EXIT; // We only handle the very first heading
30
+ }
31
+ // We only handle contentTitle if it's the very first heading found
32
+ if (headingNode.depth >= 1) {
33
+ return EXIT;
26
34
  }
27
- return EXIT; // We only handle the very first heading
28
35
  }
29
- // We only handle contentTitle if it's the very first heading found
30
- if (headingNode.depth >= 1) {
36
+ // We only handle contentTitle when it's above the first thematic break
37
+ if (node.type === 'thematicBreak') {
31
38
  return EXIT;
32
39
  }
33
40
  return undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/contentTitle/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAgBH;;;;GAIG;AACH,MAAM,MAAM,GAAW,SAAS,MAAM,CACpC,UAAyB,EAAE;IAE3B,mBAAmB;IACnB,MAAM,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,IAAI,KAAK,CAAC;IAE/D,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QAC3B,MAAM,EAAC,QAAQ,EAAC,GAAG,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC;QACxD,MAAM,EAAC,KAAK,EAAE,IAAI,EAAC,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;QAEvD,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,WAAoB,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;YAC7D,IAAI,WAAW,CAAC,KAAK,KAAK,CAAC,EAAE;gBAC3B,KAAK,CAAC,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC;gBAChD,IAAI,kBAAkB,EAAE;oBACtB,qCAAqC;oBACrC,MAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;iBACnC;gBACD,OAAO,IAAI,CAAC,CAAC,wCAAwC;aACtD;YACD,mEAAmE;YACnE,IAAI,WAAW,CAAC,KAAK,IAAI,CAAC,EAAE;gBAC1B,OAAO,IAAI,CAAC;aACb;YACD,OAAO,SAAS,CAAC;QACnB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/contentTitle/index.ts"],"names":[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1
  {
2
2
  "name": "@docusaurus/mdx-loader",
3
- "version": "0.0.0-5878",
3
+ "version": "0.0.0-5880",
4
4
  "description": "Docusaurus Loader for MDX",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -18,9 +18,9 @@
18
18
  },
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "@docusaurus/logger": "0.0.0-5878",
22
- "@docusaurus/utils": "0.0.0-5878",
23
- "@docusaurus/utils-validation": "0.0.0-5878",
21
+ "@docusaurus/logger": "0.0.0-5880",
22
+ "@docusaurus/utils": "0.0.0-5880",
23
+ "@docusaurus/utils-validation": "0.0.0-5880",
24
24
  "@mdx-js/mdx": "^3.0.0",
25
25
  "@slorber/remark-comment": "^1.0.0",
26
26
  "escape-html": "^1.0.3",
@@ -44,7 +44,7 @@
44
44
  "webpack": "^5.88.1"
45
45
  },
46
46
  "devDependencies": {
47
- "@docusaurus/types": "0.0.0-5878",
47
+ "@docusaurus/types": "0.0.0-5880",
48
48
  "@types/escape-html": "^1.0.2",
49
49
  "@types/mdast": "^4.0.2",
50
50
  "@types/stringify-object": "^3.3.1",
@@ -64,5 +64,5 @@
64
64
  "engines": {
65
65
  "node": ">=18.0"
66
66
  },
67
- "gitHead": "d12884c09795e4d0a536df1840d86a0bcbcd9a99"
67
+ "gitHead": "93c6aac5368fab67c25b6dc0beb39dfa5f6b8a1b"
68
68
  }
@@ -34,17 +34,24 @@ const plugin: Plugin = function plugin(
34
34
  const {toString} = await import('mdast-util-to-string');
35
35
  const {visit, EXIT} = await import('unist-util-visit');
36
36
 
37
- visit(root, 'heading', (headingNode: Heading, index, parent) => {
38
- if (headingNode.depth === 1) {
39
- vfile.data.contentTitle = toString(headingNode);
40
- if (removeContentTitle) {
41
- // @ts-expect-error: TODO how to fix?
42
- parent!.children.splice(index, 1);
37
+ visit(root, ['heading', 'thematicBreak'], (node, index, parent) => {
38
+ if (node.type === 'heading') {
39
+ const headingNode = node as Heading;
40
+ if (headingNode.depth === 1) {
41
+ vfile.data.contentTitle = toString(headingNode);
42
+ if (removeContentTitle) {
43
+ // @ts-expect-error: TODO how to fix?
44
+ parent!.children.splice(index, 1);
45
+ }
46
+ return EXIT; // We only handle the very first heading
47
+ }
48
+ // We only handle contentTitle if it's the very first heading found
49
+ if (headingNode.depth >= 1) {
50
+ return EXIT;
43
51
  }
44
- return EXIT; // We only handle the very first heading
45
52
  }
46
- // We only handle contentTitle if it's the very first heading found
47
- if (headingNode.depth >= 1) {
53
+ // We only handle contentTitle when it's above the first thematic break
54
+ if (node.type === 'thematicBreak') {
48
55
  return EXIT;
49
56
  }
50
57
  return undefined;