@docusaurus/mdx-loader 2.0.0-beta.18 → 2.0.0-beta.19
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.d.ts +25 -22
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -169
- package/lib/index.js.map +1 -1
- package/lib/loader.d.ts +39 -0
- package/lib/loader.d.ts.map +1 -0
- package/lib/loader.js +194 -0
- package/lib/loader.js.map +1 -0
- package/lib/remark/headings/index.d.ts.map +1 -1
- package/lib/remark/headings/index.js +1 -3
- package/lib/remark/headings/index.js.map +1 -1
- package/lib/remark/toc/index.d.ts +2 -2
- package/lib/remark/toc/index.d.ts.map +1 -1
- package/lib/remark/toc/index.js +1 -1
- package/lib/remark/toc/index.js.map +1 -1
- package/lib/remark/transformImage/index.js +2 -2
- package/lib/remark/transformImage/index.js.map +1 -1
- package/lib/remark/transformLinks/index.d.ts.map +1 -1
- package/lib/remark/transformLinks/index.js +4 -2
- package/lib/remark/transformLinks/index.js.map +1 -1
- package/package.json +16 -16
- package/src/deps.d.ts +16 -15
- package/src/index.ts +23 -213
- package/src/loader.ts +253 -0
- package/src/remark/headings/index.ts +3 -6
- package/src/remark/toc/index.ts +4 -4
- package/src/remark/transformImage/index.ts +2 -2
- package/src/remark/transformLinks/index.ts +4 -2
- package/src/mdx-loader.d.ts +0 -18
|
@@ -103,7 +103,7 @@ async function getImageAbsolutePath(
|
|
|
103
103
|
await ensureImageFileExist(imageFilePath, filePath);
|
|
104
104
|
return imageFilePath;
|
|
105
105
|
} else if (path.isAbsolute(imagePath)) {
|
|
106
|
-
//
|
|
106
|
+
// Absolute paths are expected to exist in the static folder.
|
|
107
107
|
const possiblePaths = staticDirs.map((dir) => path.join(dir, imagePath));
|
|
108
108
|
const imageFilePath = await findAsyncSequential(
|
|
109
109
|
possiblePaths,
|
|
@@ -120,7 +120,7 @@ async function getImageAbsolutePath(
|
|
|
120
120
|
}
|
|
121
121
|
return imageFilePath;
|
|
122
122
|
}
|
|
123
|
-
//
|
|
123
|
+
// Relative paths are resolved against the source file's folder.
|
|
124
124
|
const imageFilePath = path.join(
|
|
125
125
|
path.dirname(filePath),
|
|
126
126
|
decodeURIComponent(imagePath),
|
|
@@ -34,7 +34,9 @@ type Context = PluginOptions & {
|
|
|
34
34
|
filePath: string;
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Transforms the link node to a JSX `<a>` element with a `require()` call.
|
|
39
|
+
*/
|
|
38
40
|
function toAssetRequireNode(node: Link, assetPath: string, filePath: string) {
|
|
39
41
|
const jsxNode = node as Literal & Partial<Link>;
|
|
40
42
|
let relativeAssetPath = posixPath(
|
|
@@ -106,7 +108,7 @@ async function getAssetAbsolutePath(
|
|
|
106
108
|
|
|
107
109
|
async function processLinkNode(node: Link, context: Context) {
|
|
108
110
|
if (!node.url) {
|
|
109
|
-
//
|
|
111
|
+
// Try to improve error feedback
|
|
110
112
|
// see https://github.com/facebook/docusaurus/issues/3309#issuecomment-690371675
|
|
111
113
|
const title = node.title || (node.children[0] as Literal)?.value || '?';
|
|
112
114
|
const line = node?.position?.start?.line || '?';
|
package/src/mdx-loader.d.ts
DELETED
|
@@ -1,18 +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
|
-
|
|
8
|
-
import type {Plugin} from 'unified';
|
|
9
|
-
|
|
10
|
-
export type RemarkOrRehypePlugin =
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
-
[Plugin<any[]>, any] | Plugin<any[]>;
|
|
13
|
-
export type RemarkAndRehypePluginOptions = {
|
|
14
|
-
remarkPlugins: RemarkOrRehypePlugin[];
|
|
15
|
-
rehypePlugins: RemarkOrRehypePlugin[];
|
|
16
|
-
beforeDefaultRemarkPlugins: RemarkOrRehypePlugin[];
|
|
17
|
-
beforeDefaultRehypePlugins: RemarkOrRehypePlugin[];
|
|
18
|
-
};
|