@docusaurus/mdx-loader 2.0.0-beta.1ab8aa0af → 2.0.0-beta.2
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/package.json +8 -8
- package/src/index.js +7 -4
- package/src/remark/transformImage/__tests__/__snapshots__/index.test.js.snap +1 -1
- package/src/remark/transformImage/index.js +2 -2
- package/src/remark/transformLinks/__tests__/__snapshots__/index.test.js.snap +1 -1
- package/src/remark/transformLinks/index.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/mdx-loader",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.2",
|
|
4
4
|
"description": "Docusaurus Loader for MDX",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -20,24 +20,24 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@babel/parser": "^7.12.16",
|
|
22
22
|
"@babel/traverse": "^7.12.13",
|
|
23
|
-
"@docusaurus/core": "2.0.0-beta.
|
|
24
|
-
"@docusaurus/utils": "2.0.0-beta.
|
|
23
|
+
"@docusaurus/core": "2.0.0-beta.2",
|
|
24
|
+
"@docusaurus/utils": "2.0.0-beta.2",
|
|
25
25
|
"@mdx-js/mdx": "^1.6.21",
|
|
26
26
|
"@mdx-js/react": "^1.6.21",
|
|
27
27
|
"escape-html": "^1.0.3",
|
|
28
28
|
"file-loader": "^6.2.0",
|
|
29
|
-
"fs-extra": "^
|
|
29
|
+
"fs-extra": "^10.0.0",
|
|
30
30
|
"github-slugger": "^1.3.0",
|
|
31
|
-
"gray-matter": "^4.0.
|
|
31
|
+
"gray-matter": "^4.0.3",
|
|
32
32
|
"mdast-util-to-string": "^2.0.0",
|
|
33
33
|
"remark-emoji": "^2.1.0",
|
|
34
34
|
"stringify-object": "^3.3.0",
|
|
35
35
|
"unist-util-visit": "^2.0.2",
|
|
36
36
|
"url-loader": "^4.1.1",
|
|
37
|
-
"webpack": "^5.
|
|
37
|
+
"webpack": "^5.40.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@docusaurus/types": "2.0.0-beta.
|
|
40
|
+
"@docusaurus/types": "2.0.0-beta.2",
|
|
41
41
|
"remark": "^12.0.0",
|
|
42
42
|
"remark-mdx": "^1.6.21",
|
|
43
43
|
"to-vfile": "^6.0.0",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"engines": {
|
|
52
52
|
"node": ">=12.13.0"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "883f07fddffaf1657407c8e202e370cc436e25f7"
|
|
55
55
|
}
|
package/src/index.js
CHANGED
|
@@ -31,9 +31,8 @@ module.exports = async function docusaurusMdxLoader(fileString) {
|
|
|
31
31
|
|
|
32
32
|
const {frontMatter, content: contentWithTitle} = parseFrontMatter(fileString);
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
keepContentTitle: reqOptions.keepContentTitle,
|
|
34
|
+
const {content, contentTitle} = parseMarkdownContentTitle(contentWithTitle, {
|
|
35
|
+
removeContentTitle: reqOptions.removeContentTitle,
|
|
37
36
|
});
|
|
38
37
|
|
|
39
38
|
const hasFrontMatter = Object.keys(frontMatter).length > 0;
|
|
@@ -69,7 +68,11 @@ module.exports = async function docusaurusMdxLoader(fileString) {
|
|
|
69
68
|
return callback(err);
|
|
70
69
|
}
|
|
71
70
|
|
|
72
|
-
let exportStr =
|
|
71
|
+
let exportStr = ``;
|
|
72
|
+
exportStr += `\nexport const frontMatter = ${stringifyObject(frontMatter)};`;
|
|
73
|
+
exportStr += `\nexport const contentTitle = ${stringifyObject(
|
|
74
|
+
contentTitle,
|
|
75
|
+
)};`;
|
|
73
76
|
|
|
74
77
|
// Read metadata for this MDX and export it.
|
|
75
78
|
if (options.metadataPath && typeof options.metadataPath === 'function') {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`transformImage plugin fail if image does not exist 1`] = `"Image packages/docusaurus-mdx-loader/src/remark/transformImage/__tests__/fixtures/img/doesNotExist.png used in packages/docusaurus-mdx-loader/src/remark/transformImage/__tests__/fixtures/fail.md not found."`;
|
|
4
4
|
|
|
5
|
-
exports[`transformImage plugin fail if image url is absent 1`] = `"Markdown image
|
|
5
|
+
exports[`transformImage plugin fail if image url is absent 1`] = `"Markdown image URL is mandatory in \\"packages/docusaurus-mdx-loader/src/remark/transformImage/__tests__/fixtures/noUrl.md\\" file"`;
|
|
6
6
|
|
|
7
7
|
exports[`transformImage plugin pathname protocol 1`] = `
|
|
8
8
|
"
|
|
@@ -57,9 +57,9 @@ async function ensureImageFileExist(imagePath, sourceFilePath) {
|
|
|
57
57
|
async function processImageNode(node, {filePath, staticDir}) {
|
|
58
58
|
if (!node.url) {
|
|
59
59
|
throw new Error(
|
|
60
|
-
`Markdown image
|
|
60
|
+
`Markdown image URL is mandatory in "${toMessageRelativeFilePath(
|
|
61
61
|
filePath,
|
|
62
|
-
)}`,
|
|
62
|
+
)}" file`,
|
|
63
63
|
);
|
|
64
64
|
}
|
|
65
65
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`transformAsset plugin fail if asset url is absent 1`] = `"Markdown link
|
|
3
|
+
exports[`transformAsset plugin fail if asset url is absent 1`] = `"Markdown link URL is mandatory in \\"packages/docusaurus-mdx-loader/src/remark/transformLinks/__tests__/fixtures/noUrl.md\\" file (title: asset, line: 1)."`;
|
|
4
4
|
|
|
5
5
|
exports[`transformAsset plugin pathname protocol 1`] = `
|
|
6
6
|
"[asset](pathname:///asset/unchecked.pdf)
|
|
@@ -111,9 +111,9 @@ async function processLinkNode({node, _index, _parent, filePath, staticDir}) {
|
|
|
111
111
|
const line =
|
|
112
112
|
(node.position && node.position.start && node.position.start.line) || '?';
|
|
113
113
|
throw new Error(
|
|
114
|
-
`Markdown link
|
|
114
|
+
`Markdown link URL is mandatory in "${toMessageRelativeFilePath(
|
|
115
115
|
filePath,
|
|
116
|
-
)}
|
|
116
|
+
)}" file (title: ${title}, line: ${line}).`,
|
|
117
117
|
);
|
|
118
118
|
}
|
|
119
119
|
|