@azerion/bunosaurus-mdx-loader 0.0.0-stage → 4.0.0
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/README.md +57 -2
- package/lib/createMDXLoader.d.ts +14 -0
- package/lib/createMDXLoader.d.ts.map +1 -0
- package/lib/createMDXLoader.js +52 -0
- package/lib/createMDXLoader.js.map +1 -0
- package/lib/format.d.ts +14 -0
- package/lib/format.d.ts.map +1 -0
- package/lib/format.js +41 -0
- package/lib/format.js.map +1 -0
- package/lib/frontMatter.d.ts +13 -0
- package/lib/frontMatter.d.ts.map +1 -0
- package/lib/frontMatter.js +23 -0
- package/lib/frontMatter.js.map +1 -0
- package/lib/index.d.ts +35 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +15 -0
- package/lib/index.js.map +1 -0
- package/lib/loader.d.ts +11 -0
- package/lib/loader.d.ts.map +1 -0
- package/lib/loader.js +170 -0
- package/lib/loader.js.map +1 -0
- package/lib/options.d.ts +35 -0
- package/lib/options.d.ts.map +1 -0
- package/lib/options.js +9 -0
- package/lib/options.js.map +1 -0
- package/lib/preprocessor.d.ts +18 -0
- package/lib/preprocessor.d.ts.map +1 -0
- package/lib/preprocessor.js +34 -0
- package/lib/preprocessor.js.map +1 -0
- package/lib/processor.d.ts +49 -0
- package/lib/processor.d.ts.map +1 -0
- package/lib/processor.js +209 -0
- package/lib/processor.js.map +1 -0
- package/lib/remark/admonitions/index.d.ts +11 -0
- package/lib/remark/admonitions/index.d.ts.map +1 -0
- package/lib/remark/admonitions/index.js +107 -0
- package/lib/remark/admonitions/index.js.map +1 -0
- package/lib/remark/contentTitle/index.d.ts +13 -0
- package/lib/remark/contentTitle/index.d.ts.map +1 -0
- package/lib/remark/contentTitle/index.js +62 -0
- package/lib/remark/contentTitle/index.js.map +1 -0
- package/lib/remark/details/index.d.ts +10 -0
- package/lib/remark/details/index.d.ts.map +1 -0
- package/lib/remark/details/index.js +22 -0
- package/lib/remark/details/index.js.map +1 -0
- package/lib/remark/head/index.d.ts +10 -0
- package/lib/remark/head/index.d.ts.map +1 -0
- package/lib/remark/head/index.js +22 -0
- package/lib/remark/head/index.js.map +1 -0
- package/lib/remark/headings/index.d.ts +14 -0
- package/lib/remark/headings/index.d.ts.map +1 -0
- package/lib/remark/headings/index.js +126 -0
- package/lib/remark/headings/index.js.map +1 -0
- package/lib/remark/mdx1Compat/codeCompatPlugin.d.ts +11 -0
- package/lib/remark/mdx1Compat/codeCompatPlugin.d.ts.map +1 -0
- package/lib/remark/mdx1Compat/codeCompatPlugin.js +30 -0
- package/lib/remark/mdx1Compat/codeCompatPlugin.js.map +1 -0
- package/lib/remark/mermaid/index.d.ts +10 -0
- package/lib/remark/mermaid/index.d.ts.map +1 -0
- package/lib/remark/mermaid/index.js +34 -0
- package/lib/remark/mermaid/index.js.map +1 -0
- package/lib/remark/resolveMarkdownLinks/index.d.ts +33 -0
- package/lib/remark/resolveMarkdownLinks/index.d.ts.map +1 -0
- package/lib/remark/resolveMarkdownLinks/index.js +87 -0
- package/lib/remark/resolveMarkdownLinks/index.js.map +1 -0
- package/lib/remark/toc/index.d.ts +14 -0
- package/lib/remark/toc/index.d.ts.map +1 -0
- package/lib/remark/toc/index.js +115 -0
- package/lib/remark/toc/index.js.map +1 -0
- package/lib/remark/toc/types.d.ts +22 -0
- package/lib/remark/toc/types.d.ts.map +1 -0
- package/lib/remark/toc/types.js +9 -0
- package/lib/remark/toc/types.js.map +1 -0
- package/lib/remark/toc/utils.d.ts +26 -0
- package/lib/remark/toc/utils.d.ts.map +1 -0
- package/lib/remark/toc/utils.js +184 -0
- package/lib/remark/toc/utils.js.map +1 -0
- package/lib/remark/transformImage/index.d.ts +17 -0
- package/lib/remark/transformImage/index.d.ts.map +1 -0
- package/lib/remark/transformImage/index.js +187 -0
- package/lib/remark/transformImage/index.js.map +1 -0
- package/lib/remark/transformLinks/index.d.ts +17 -0
- package/lib/remark/transformLinks/index.d.ts.map +1 -0
- package/lib/remark/transformLinks/index.js +205 -0
- package/lib/remark/transformLinks/index.js.map +1 -0
- package/lib/remark/unusedDirectives/index.d.ts +9 -0
- package/lib/remark/unusedDirectives/index.d.ts.map +1 -0
- package/lib/remark/unusedDirectives/index.js +125 -0
- package/lib/remark/unusedDirectives/index.js.map +1 -0
- package/lib/remark/utils/index.d.ts +18 -0
- package/lib/remark/utils/index.d.ts.map +1 -0
- package/lib/remark/utils/index.js +93 -0
- package/lib/remark/utils/index.js.map +1 -0
- package/lib/serializeJS.d.ts +17 -0
- package/lib/serializeJS.d.ts.map +1 -0
- package/lib/serializeJS.js +24 -0
- package/lib/serializeJS.js.map +1 -0
- package/lib/utils.d.ts +35 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +97 -0
- package/lib/utils.js.map +1 -0
- package/package.json +65 -4
- package/src/createMDXLoader.ts +65 -0
- package/src/format.ts +50 -0
- package/src/frontMatter.ts +31 -0
- package/src/index.ts +44 -0
- package/src/loader.ts +227 -0
- package/src/options.ts +37 -0
- package/src/preprocessor.ts +47 -0
- package/src/processor.ts +306 -0
- package/src/remark/admonitions/LICENSE +45 -0
- package/src/remark/admonitions/README.md +3 -0
- package/src/remark/admonitions/index.ts +138 -0
- package/src/remark/contentTitle/index.ts +76 -0
- package/src/remark/details/index.ts +23 -0
- package/src/remark/head/index.ts +23 -0
- package/src/remark/headings/index.ts +158 -0
- package/src/remark/mdx1Compat/codeCompatPlugin.ts +35 -0
- package/src/remark/mermaid/index.ts +35 -0
- package/src/remark/resolveMarkdownLinks/index.ts +137 -0
- package/src/remark/toc/index.ts +183 -0
- package/src/remark/toc/types.ts +29 -0
- package/src/remark/toc/utils.ts +243 -0
- package/src/remark/transformImage/index.ts +268 -0
- package/src/remark/transformLinks/index.ts +291 -0
- package/src/remark/unusedDirectives/index.ts +171 -0
- package/src/remark/utils/index.ts +99 -0
- package/src/serializeJS.ts +22 -0
- package/src/types.d.mts +40 -0
- package/src/utils.ts +134 -0
package/README.md
CHANGED
|
@@ -1,3 +1,58 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@docusaurus/mdx-loader`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Docusaurus webpack loader for [MDX](https://github.com/mdx-js/mdx).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
yarn add @docusaurus/mdx-loader
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
// ...
|
|
15
|
+
module: {
|
|
16
|
+
rules: [
|
|
17
|
+
// ...
|
|
18
|
+
{
|
|
19
|
+
test: /\.mdx?$/,
|
|
20
|
+
use: [
|
|
21
|
+
{
|
|
22
|
+
loader: '@docusaurus/mdx-loader',
|
|
23
|
+
options: {
|
|
24
|
+
// .. See options
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Options
|
|
34
|
+
|
|
35
|
+
### `rehypePlugins`
|
|
36
|
+
|
|
37
|
+
Array of rehype plugins to manipulate the MDXHAST
|
|
38
|
+
|
|
39
|
+
### `remarkPlugins`
|
|
40
|
+
|
|
41
|
+
Array of remark plugins to manipulate the MDXAST
|
|
42
|
+
|
|
43
|
+
### `metadataPath`
|
|
44
|
+
|
|
45
|
+
A function to provide the metadataPath depending on current loaded MDX path that will be exported as the MDX metadata.
|
|
46
|
+
|
|
47
|
+
### `markdownConfig`
|
|
48
|
+
|
|
49
|
+
The global Docusaurus Markdown config (`config.markdown`), that plugin authors should forward:
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
const loader = {
|
|
53
|
+
loader: require.resolve('@docusaurus/mdx-loader'),
|
|
54
|
+
options: {
|
|
55
|
+
markdownConfig: siteConfig.markdown,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
```
|
|
@@ -0,0 +1,14 @@
|
|
|
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 { Options } from './options';
|
|
8
|
+
import type { RuleSetRule, RuleSetUseItem } from 'webpack';
|
|
9
|
+
export declare function createMDXLoaderItem(options: Options): RuleSetUseItem;
|
|
10
|
+
export declare function createMDXLoaderRule({ include, options, }: {
|
|
11
|
+
include: RuleSetRule['include'];
|
|
12
|
+
options: Options;
|
|
13
|
+
}): RuleSetRule;
|
|
14
|
+
//# sourceMappingURL=createMDXLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createMDXLoader.d.ts","sourceRoot":"","sources":["../src/createMDXLoader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAC,WAAW,EAAE,cAAc,EAAC,MAAM,SAAS,CAAC;AAmCzD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,cAAc,CAKpE;AAED,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,OAAO,GACR,EAAE;IACD,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,EAAE,OAAO,CAAC;CAClB,GAAG,WAAW,CAOd"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.createMDXLoaderItem = createMDXLoaderItem;
|
|
10
|
+
exports.createMDXLoaderRule = createMDXLoaderRule;
|
|
11
|
+
const processor_1 = require("./processor");
|
|
12
|
+
// Escape hatch to disable the MDX cross-compiler cache, just in case
|
|
13
|
+
// TODO Docusaurus v5: remove this escape hatch env variable
|
|
14
|
+
const DisableCrossCompilerCache = process.env.DOCUSAURUS_NO_MDX_CROSS_COMPILER_CACHE === 'true';
|
|
15
|
+
function normalizeOptions(optionsInput) {
|
|
16
|
+
// Skip eager processor creation in tests
|
|
17
|
+
if (process.env.NODE_ENV === 'test' || process.env.VITEST) {
|
|
18
|
+
return optionsInput;
|
|
19
|
+
}
|
|
20
|
+
let options = optionsInput;
|
|
21
|
+
// We create the processor earlier here, to avoid the lazy processor creating
|
|
22
|
+
// Lazy creation messes-up with Rsdoctor ability to measure mdx-loader perf
|
|
23
|
+
if (!options.processors) {
|
|
24
|
+
options = { ...options, processors: (0, processor_1.createProcessors)({ options }) };
|
|
25
|
+
}
|
|
26
|
+
// Cross-compiler cache permits to compile client/server MDX only once
|
|
27
|
+
// We don't want to cache in dev mode (docusaurus start)
|
|
28
|
+
// We only have multiple compilers in production mode (docusaurus build)
|
|
29
|
+
// TODO wrong but good enough for now (example: "docusaurus build --dev")
|
|
30
|
+
if (!DisableCrossCompilerCache && process.env.NODE_ENV === 'production') {
|
|
31
|
+
options = {
|
|
32
|
+
...options,
|
|
33
|
+
crossCompilerCache: new Map(),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return options;
|
|
37
|
+
}
|
|
38
|
+
function createMDXLoaderItem(options) {
|
|
39
|
+
return {
|
|
40
|
+
loader: require.resolve('./index'),
|
|
41
|
+
options: normalizeOptions(options),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function createMDXLoaderRule({ include, options, }) {
|
|
45
|
+
return {
|
|
46
|
+
test: /\.mdx?$/i,
|
|
47
|
+
include,
|
|
48
|
+
with: { type: { not: 'text' } },
|
|
49
|
+
use: [createMDXLoaderItem(options)],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=createMDXLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createMDXLoader.js","sourceRoot":"","sources":["../src/createMDXLoader.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,2CAA6C;AAI7C,qEAAqE;AACrE,4DAA4D;AAC5D,MAAM,yBAAyB,GAC7B,OAAO,CAAC,GAAG,CAAC,sCAAsC,KAAK,MAAM,CAAC;AAEhE,SAAS,gBAAgB,CAAC,YAAqB;IAC7C,yCAAyC;IACzC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;QAC1D,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,IAAI,OAAO,GAAG,YAAY,CAAC;IAE3B,6EAA6E;IAC7E,2EAA2E;IAC3E,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QACxB,OAAO,GAAG,EAAC,GAAG,OAAO,EAAE,UAAU,EAAE,IAAA,4BAAgB,EAAC,EAAC,OAAO,EAAC,CAAC,EAAC,CAAC;IAClE,CAAC;IAED,sEAAsE;IACtE,wDAAwD;IACxD,wEAAwE;IACxE,yEAAyE;IACzE,IAAI,CAAC,yBAAyB,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;QACxE,OAAO,GAAG;YACR,GAAG,OAAO;YACV,kBAAkB,EAAE,IAAI,GAAG,EAAE;SAC9B,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,6BAAoC,OAAgB;IAClD,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC;QAClC,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC;KACnC,CAAC;AACJ,CAAC;AAED,6BAAoC,EAClC,OAAO,EACP,OAAO,GAIR;IACC,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,OAAO;QACP,IAAI,EAAE,EAAC,IAAI,EAAE,EAAC,GAAG,EAAE,MAAM,EAAC,EAAC;QAC3B,GAAG,EAAE,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;KACpC,CAAC;AACJ,CAAC"}
|
package/lib/format.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
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 { MDXFrontMatter } from './frontMatter';
|
|
8
|
+
import type { Format, FormatInput } from './index';
|
|
9
|
+
export declare function getFormat({ filePath, frontMatterFormat, markdownConfigFormat, }: {
|
|
10
|
+
filePath: string;
|
|
11
|
+
frontMatterFormat: MDXFrontMatter['format'];
|
|
12
|
+
markdownConfigFormat: FormatInput;
|
|
13
|
+
}): Format;
|
|
14
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,SAAS,CAAC;AAqBjD,wBAAgB,SAAS,CAAC,EACxB,QAAQ,EACR,iBAAiB,EACjB,oBAAoB,GACrB,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC5C,oBAAoB,EAAE,WAAW,CAAC;CACnC,GAAG,MAAM,CAWT"}
|
package/lib/format.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.getFormat = getFormat;
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
11
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
12
|
+
// Copied from https://mdxjs.com/packages/mdx/#optionsmdextensions
|
|
13
|
+
// Although we are likely to only use .md / .mdx anyway...
|
|
14
|
+
const mdFormatExtensions = [
|
|
15
|
+
'.md',
|
|
16
|
+
'.markdown',
|
|
17
|
+
'.mdown',
|
|
18
|
+
'.mkdn',
|
|
19
|
+
'.mkd',
|
|
20
|
+
'.mdwn',
|
|
21
|
+
'.mkdown',
|
|
22
|
+
'.ron',
|
|
23
|
+
];
|
|
24
|
+
function getExtensionFormat(filepath) {
|
|
25
|
+
const isMDFormat = mdFormatExtensions.includes(node_path_1.default.extname(filepath));
|
|
26
|
+
// Bias toward mdx if unknown extension
|
|
27
|
+
return isMDFormat ? 'md' : 'mdx';
|
|
28
|
+
}
|
|
29
|
+
function getFormat({ filePath, frontMatterFormat, markdownConfigFormat, }) {
|
|
30
|
+
if (frontMatterFormat) {
|
|
31
|
+
if (frontMatterFormat !== 'detect') {
|
|
32
|
+
return frontMatterFormat;
|
|
33
|
+
}
|
|
34
|
+
return getExtensionFormat(filePath);
|
|
35
|
+
}
|
|
36
|
+
if (markdownConfigFormat !== 'detect') {
|
|
37
|
+
return markdownConfigFormat;
|
|
38
|
+
}
|
|
39
|
+
return getExtensionFormat(filePath);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,kEAA6B;AAI7B,kEAAkE;AAClE,0DAA0D;AAC1D,MAAM,kBAAkB,GAAG;IACzB,KAAK;IACL,WAAW;IACX,QAAQ;IACR,OAAO;IACP,MAAM;IACN,OAAO;IACP,SAAS;IACT,MAAM;CACP,CAAC;AAEF,SAAS,kBAAkB,CAAC,QAAgB;IAC1C,MAAM,UAAU,GAAG,kBAAkB,CAAC,QAAQ,CAAC,mBAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IACvE,uCAAuC;IACvC,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AACnC,CAAC;AAED,mBAA0B,EACxB,QAAQ,EACR,iBAAiB,EACjB,oBAAoB,GAKrB;IACC,IAAI,iBAAiB,EAAE,CAAC;QACtB,IAAI,iBAAiB,KAAK,QAAQ,EAAE,CAAC;YACnC,OAAO,iBAAiB,CAAC;QAC3B,CAAC;QACD,OAAO,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IACtC,CAAC;IACD,IAAI,oBAAoB,KAAK,QAAQ,EAAE,CAAC;QACtC,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IACD,OAAO,kBAAkB,CAAC,QAAQ,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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 { FormatInput } from './index';
|
|
8
|
+
export type MDXFrontMatter = {
|
|
9
|
+
format?: FormatInput;
|
|
10
|
+
};
|
|
11
|
+
export declare const DefaultMDXFrontMatter: MDXFrontMatter;
|
|
12
|
+
export declare function validateMDXFrontMatter(frontMatter: unknown): MDXFrontMatter;
|
|
13
|
+
//# sourceMappingURL=frontMatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontMatter.d.ts","sourceRoot":"","sources":["../src/frontMatter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAEzC,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,cAEnC,CAAC;AAMF,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,OAAO,GAAG,cAAc,CAI3E"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.DefaultMDXFrontMatter = void 0;
|
|
10
|
+
exports.validateMDXFrontMatter = validateMDXFrontMatter;
|
|
11
|
+
const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
12
|
+
exports.DefaultMDXFrontMatter = {
|
|
13
|
+
format: undefined,
|
|
14
|
+
};
|
|
15
|
+
const MDXFrontMatterSchema = utils_validation_1.JoiFrontMatter.object({
|
|
16
|
+
format: utils_validation_1.JoiFrontMatter.string().equal('md', 'mdx', 'detect').optional(),
|
|
17
|
+
}).default(exports.DefaultMDXFrontMatter);
|
|
18
|
+
function validateMDXFrontMatter(frontMatter) {
|
|
19
|
+
return (0, utils_validation_1.validateFrontMatter)(frontMatter, MDXFrontMatterSchema, {
|
|
20
|
+
allowUnknown: false,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=frontMatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontMatter.js","sourceRoot":"","sources":["../src/frontMatter.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,mEAGsC;AAQzB,QAAA,qBAAqB,GAAmB;IACnD,MAAM,EAAE,SAAS;CAClB,CAAC;AAEF,MAAM,oBAAoB,GAAG,iCAAG,CAAC,MAAM,CAAiB;IACtD,MAAM,EAAE,iCAAG,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE;CAC7D,CAAC,CAAC,OAAO,CAAC,QAAA,qBAAqB,CAAC,CAAC;AAElC,gCAAuC,WAAoB;IACzD,OAAO,IAAA,sCAAmB,EAAC,WAAW,EAAE,oBAAoB,EAAE;QAC5D,YAAY,EAAE,KAAK;KACpB,CAAC,CAAC;AACL,CAAC"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
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 { ReactNode } from 'react';
|
|
8
|
+
import { mdxLoader } from './loader';
|
|
9
|
+
import type { TOCItem as TOCItemImported } from './remark/toc/types';
|
|
10
|
+
export { createMDXLoaderRule, createMDXLoaderItem } from './createMDXLoader';
|
|
11
|
+
export default mdxLoader;
|
|
12
|
+
export type TOCItem = TOCItemImported;
|
|
13
|
+
export type Format = 'md' | 'mdx';
|
|
14
|
+
export type FormatInput = Format | 'detect';
|
|
15
|
+
export type LoadedMDXContent<FrontMatter, Metadata, Assets = undefined> = {
|
|
16
|
+
/** As verbatim declared in the MDX document. */
|
|
17
|
+
readonly frontMatter: FrontMatter;
|
|
18
|
+
/** As provided by the content plugin. */
|
|
19
|
+
readonly metadata: Metadata;
|
|
20
|
+
/** A list of TOC items (headings). */
|
|
21
|
+
readonly toc: readonly TOCItem[];
|
|
22
|
+
/** First h1 title before any content. */
|
|
23
|
+
readonly contentTitle: string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Usually image assets that may be collocated like `./img/thumbnail.png`.
|
|
26
|
+
* The loader would also bundle these assets and the client should use these
|
|
27
|
+
* in priority.
|
|
28
|
+
*/
|
|
29
|
+
readonly assets: Assets;
|
|
30
|
+
(): ReactNode;
|
|
31
|
+
};
|
|
32
|
+
export type { MDXPlugin } from './loader';
|
|
33
|
+
export type { MDXOptions } from './processor';
|
|
34
|
+
export type { Options } from './options';
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAErC,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAC;AAEnC,OAAO,KAAK,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,oBAAoB,CAAC;AAEnE,OAAO,EAAC,mBAAmB,EAAE,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;eAE5D,SAAS;AAExB,MAAM,MAAM,OAAO,GAAG,eAAe,CAAC;AAEtC,MAAM,MAAM,MAAM,GAAG,IAAI,GAAG,KAAK,CAAC;AAElC,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE5C,MAAM,MAAM,gBAAgB,CAAC,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,IAAI;IACxE,gDAAgD;IAChD,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,yCAAyC;IACzC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,sCAAsC;IACtC,QAAQ,CAAC,GAAG,EAAE,SAAS,OAAO,EAAE,CAAC;IACjC,yCAAyC;IACzC,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,IAAI,SAAS,CAAC;CACf,CAAC;AAEF,YAAY,EAAC,SAAS,EAAC,MAAM,UAAU,CAAC;AACxC,YAAY,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.createMDXLoaderItem = exports.createMDXLoaderRule = void 0;
|
|
10
|
+
const loader_1 = require("./loader");
|
|
11
|
+
var createMDXLoader_1 = require("./createMDXLoader");
|
|
12
|
+
Object.defineProperty(exports, "createMDXLoaderRule", { enumerable: true, get: function () { return createMDXLoader_1.createMDXLoaderRule; } });
|
|
13
|
+
Object.defineProperty(exports, "createMDXLoaderItem", { enumerable: true, get: function () { return createMDXLoader_1.createMDXLoaderItem; } });
|
|
14
|
+
exports.default = loader_1.mdxLoader;
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAIH,qCAAmC;AAInC,qDAA2E;AAAnE,sHAAA,mBAAmB,OAAA;AAAE,sHAAA,mBAAmB,OAAA;kBAEjC,kBAAS"}
|
package/lib/loader.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
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 { Options } from './options';
|
|
8
|
+
import type { LoaderContext } from 'webpack';
|
|
9
|
+
export type { MDXPlugin } from './processor';
|
|
10
|
+
export declare function mdxLoader(this: LoaderContext<Options>, fileContent: string): Promise<void>;
|
|
11
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgBH,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,SAAS,CAAC;AAC3C,YAAY,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAuL3C,wBAAsB,SAAS,CAC7B,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,EAC5B,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAiBf"}
|
package/lib/loader.js
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.mdxLoader = mdxLoader;
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
11
|
+
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
12
|
+
const utils_1 = require("@docusaurus/utils");
|
|
13
|
+
const utils_2 = require("./utils");
|
|
14
|
+
const serializeJS_1 = require("./serializeJS");
|
|
15
|
+
async function loadMDX({ fileContent, filePath, options, compilerName, }) {
|
|
16
|
+
const { frontMatter } = await options.markdownConfig.parseFrontMatter({
|
|
17
|
+
filePath,
|
|
18
|
+
fileContent,
|
|
19
|
+
defaultParseFrontMatter: utils_1.DEFAULT_PARSE_FRONT_MATTER,
|
|
20
|
+
});
|
|
21
|
+
const hasFrontMatter = Object.keys(frontMatter).length > 0;
|
|
22
|
+
const result = await (0, utils_2.compileToJSX)({
|
|
23
|
+
fileContent,
|
|
24
|
+
filePath,
|
|
25
|
+
frontMatter,
|
|
26
|
+
options,
|
|
27
|
+
compilerName,
|
|
28
|
+
});
|
|
29
|
+
const contentTitle = (0, utils_2.extractContentTitleData)(result.data);
|
|
30
|
+
// MDX partials are MDX files starting with _ or in a folder starting with _
|
|
31
|
+
// Partial are not expected to have associated metadata files or front matter
|
|
32
|
+
const isMDXPartial = options.isMDXPartial?.(filePath);
|
|
33
|
+
if (isMDXPartial && hasFrontMatter) {
|
|
34
|
+
const errorMessage = `Docusaurus MDX partial files should not contain front matter.
|
|
35
|
+
Those partial files use the _ prefix as a convention by default, but this is configurable.
|
|
36
|
+
File at ${filePath} contains front matter that will be ignored:
|
|
37
|
+
${JSON.stringify(frontMatter, null, 2)}`;
|
|
38
|
+
if (!options.isMDXPartialFrontMatterWarningDisabled) {
|
|
39
|
+
const shouldError = process.env.NODE_ENV === 'test' || process.env.CI;
|
|
40
|
+
if (shouldError) {
|
|
41
|
+
throw new Error(errorMessage);
|
|
42
|
+
}
|
|
43
|
+
logger_1.default.warn(errorMessage);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const metadataPath = (function getMetadataPath() {
|
|
47
|
+
if (!isMDXPartial) {
|
|
48
|
+
return options.metadataPath?.(filePath);
|
|
49
|
+
}
|
|
50
|
+
return undefined;
|
|
51
|
+
})();
|
|
52
|
+
const assets = options.createAssets && !isMDXPartial
|
|
53
|
+
? options.createAssets({ filePath, frontMatter })
|
|
54
|
+
: undefined;
|
|
55
|
+
const fileLoaderUtils = (0, utils_1.getFileLoaderUtils)(compilerName === 'server');
|
|
56
|
+
// TODO use remark plugins to insert extra exports instead of string concat?
|
|
57
|
+
// cf how the toc is exported
|
|
58
|
+
const exportsCode = `
|
|
59
|
+
export const frontMatter = ${(0, serializeJS_1.serializeJS)(frontMatter)};
|
|
60
|
+
export const contentTitle = ${(0, serializeJS_1.serializeJS)(contentTitle)};
|
|
61
|
+
${metadataPath
|
|
62
|
+
? `export {default as metadata} from '${(0, utils_1.aliasedSitePath)(metadataPath, options.siteDir)}'`
|
|
63
|
+
: ''}
|
|
64
|
+
${assets
|
|
65
|
+
? `export const assets = ${(0, utils_2.createAssetsExportCode)({
|
|
66
|
+
assets,
|
|
67
|
+
inlineMarkdownAssetImageFileLoader: fileLoaderUtils.loaders.inlineMarkdownAssetImageFileLoader,
|
|
68
|
+
})};`
|
|
69
|
+
: ''}
|
|
70
|
+
`;
|
|
71
|
+
const code = `
|
|
72
|
+
${exportsCode}
|
|
73
|
+
${result.content}
|
|
74
|
+
`;
|
|
75
|
+
return code;
|
|
76
|
+
}
|
|
77
|
+
// Note: we cache promises instead of strings
|
|
78
|
+
// This is because client/server compilations might be triggered in parallel
|
|
79
|
+
// When this happens for the same file, we don't want to compile it twice
|
|
80
|
+
async function loadMDXWithCaching({ resource, fileContent, filePath, options, compilerName, }) {
|
|
81
|
+
const { crossCompilerCache } = options;
|
|
82
|
+
if (!crossCompilerCache) {
|
|
83
|
+
return loadMDX({
|
|
84
|
+
fileContent,
|
|
85
|
+
filePath,
|
|
86
|
+
options,
|
|
87
|
+
compilerName,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
// Note we "resource" as cache key, not "filePath" nor "fileContent"
|
|
91
|
+
// This is because:
|
|
92
|
+
// - the same file can be compiled in different variants (blog.mdx?truncated)
|
|
93
|
+
// - the same content can be processed differently (versioned docs links)
|
|
94
|
+
const cacheKey = resource;
|
|
95
|
+
// We can clean up the cache and free memory after cache entry consumption
|
|
96
|
+
// We know there are only 2 compilations for the same file
|
|
97
|
+
// Note: once we introduce RSCs we'll probably have 3 compilations
|
|
98
|
+
// Note: we can't use string keys in WeakMap
|
|
99
|
+
// But we could eventually use WeakRef for the values
|
|
100
|
+
const deleteCacheEntry = () => crossCompilerCache.delete(cacheKey);
|
|
101
|
+
const cacheEntry = crossCompilerCache?.get(cacheKey);
|
|
102
|
+
// When deduplicating client/server compilations, we always use the client
|
|
103
|
+
// compilation and not the server compilation
|
|
104
|
+
// This is important because the server compilation usually skips some steps
|
|
105
|
+
// Notably: the server compilation does not emit file-loader assets
|
|
106
|
+
// Using the server compilation otherwise leads to broken images
|
|
107
|
+
// See https://github.com/facebook/docusaurus/issues/10544#issuecomment-2390943794
|
|
108
|
+
// See https://github.com/facebook/docusaurus/pull/10553
|
|
109
|
+
// TODO a problem with this: server bundle will use client inline loaders
|
|
110
|
+
// This means server bundle will use ?emit=true for assets
|
|
111
|
+
// We should try to get rid of inline loaders to cleanup this caching logic
|
|
112
|
+
if (compilerName === 'client') {
|
|
113
|
+
const promise = loadMDX({
|
|
114
|
+
fileContent,
|
|
115
|
+
filePath,
|
|
116
|
+
options,
|
|
117
|
+
compilerName,
|
|
118
|
+
});
|
|
119
|
+
if (cacheEntry) {
|
|
120
|
+
promise.then(cacheEntry.resolve, cacheEntry.reject);
|
|
121
|
+
deleteCacheEntry();
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
const noop = () => {
|
|
125
|
+
throw new Error('this should never be called');
|
|
126
|
+
};
|
|
127
|
+
crossCompilerCache.set(cacheKey, {
|
|
128
|
+
promise,
|
|
129
|
+
resolve: noop,
|
|
130
|
+
reject: noop,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return promise;
|
|
134
|
+
}
|
|
135
|
+
// Server compilation always uses the result of the client compilation above
|
|
136
|
+
else if (compilerName === 'server') {
|
|
137
|
+
if (cacheEntry) {
|
|
138
|
+
deleteCacheEntry();
|
|
139
|
+
return cacheEntry.promise;
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
const { promise, resolve, reject } = Promise.withResolvers();
|
|
143
|
+
crossCompilerCache.set(cacheKey, { promise, resolve, reject });
|
|
144
|
+
return promise;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
throw new Error(`Unexpected compilerName=${compilerName}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
async function mdxLoader(fileContent) {
|
|
152
|
+
const compilerName = (0, utils_1.getWebpackLoaderCompilerName)(this);
|
|
153
|
+
const callback = this.async();
|
|
154
|
+
const options = this.getOptions();
|
|
155
|
+
options.dependencies?.forEach(this.addDependency);
|
|
156
|
+
try {
|
|
157
|
+
const result = await loadMDXWithCaching({
|
|
158
|
+
resource: this.resource,
|
|
159
|
+
filePath: this.resourcePath,
|
|
160
|
+
fileContent,
|
|
161
|
+
options,
|
|
162
|
+
compilerName,
|
|
163
|
+
});
|
|
164
|
+
return callback(null, result);
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
return callback(error);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,wEAAwC;AACxC,6CAK2B;AAC3B,mCAIiB;AACjB,+CAA0C;AAM1C,KAAK,UAAU,OAAO,CAAC,EACrB,WAAW,EACX,QAAQ,EACR,OAAO,EACP,YAAY,GAMb;IACC,MAAM,EAAC,WAAW,EAAC,GAAG,MAAM,OAAO,CAAC,cAAc,CAAC,gBAAgB,CAAC;QAClE,QAAQ;QACR,WAAW;QACX,uBAAuB,EAAE,kCAA0B;KACpD,CAAC,CAAC;IAEH,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IAE3D,MAAM,MAAM,GAAG,MAAM,IAAA,oBAAY,EAAC;QAChC,WAAW;QACX,QAAQ;QACR,WAAW;QACX,OAAO;QACP,YAAY;KACb,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,IAAA,+BAAuB,EAAC,MAAM,CAAC,IA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AO,CAAC,YAAY,EAAE,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAClD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,kBAAkB,CAAC;YACtC,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,YAAY;YAC3B,WAAW;YACX,OAAO;YACP,YAAY;SACb,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAChC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,QAAQ,CAAC,KAAc,CAAC,CAAC;IAClC,CAAC;AACH,CAAC"}
|
package/lib/options.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
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 { MDXOptions, SimpleProcessors } from './processor';
|
|
8
|
+
import type { MarkdownConfig } from '@docusaurus/types';
|
|
9
|
+
import type { ResolveMarkdownLink } from './remark/resolveMarkdownLinks';
|
|
10
|
+
import type { Options as RemarkMdxOptions } from 'remark-mdx';
|
|
11
|
+
export type Options = Partial<MDXOptions> & {
|
|
12
|
+
dependencies?: string[];
|
|
13
|
+
markdownConfig: MarkdownConfig;
|
|
14
|
+
staticDirs: string[];
|
|
15
|
+
siteDir: string;
|
|
16
|
+
isMDXPartial?: (filePath: string) => boolean;
|
|
17
|
+
isMDXPartialFrontMatterWarningDisabled?: boolean;
|
|
18
|
+
removeContentTitle?: boolean;
|
|
19
|
+
metadataPath?: (filePath: string) => string;
|
|
20
|
+
createAssets?: (metadata: {
|
|
21
|
+
filePath: string;
|
|
22
|
+
frontMatter: {
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
};
|
|
25
|
+
}) => {
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
};
|
|
28
|
+
resolveMarkdownLink?: ResolveMarkdownLink;
|
|
29
|
+
remarkMdxOptions?: RemarkMdxOptions;
|
|
30
|
+
processors?: SimpleProcessors;
|
|
31
|
+
crossCompilerCache?: Map<string, CrossCompilerCacheEntry>;
|
|
32
|
+
};
|
|
33
|
+
type CrossCompilerCacheEntry = PromiseWithResolvers<string>;
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAC,UAAU,EAAE,gBAAgB,EAAC,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,+BAA+B,CAAC;AACvE,OAAO,KAAK,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,YAAY,CAAC;AAE5D,MAAM,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG;IAC1C,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB,cAAc,EAAE,cAAc,CAAC;IAC/B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;IAC7C,sCAAsC,CAAC,EAAE,OAAO,CAAC;IACjD,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;IAC5C,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE;QACxB,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE;YAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;SAAC,CAAC;KACvC,KAAK;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAC,CAAC;IAC/B,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAG1C,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IAGpC,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,kBAAkB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;CAC3D,CAAC;AAEF,KAAK,uBAAuB,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC"}
|
package/lib/options.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
//# sourceMappingURL=options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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 { Options } from './options';
|
|
8
|
+
/**
|
|
9
|
+
* Preprocess the string before passing it to MDX
|
|
10
|
+
* This is not particularly recommended but makes it easier to upgrade to MDX 2
|
|
11
|
+
*/
|
|
12
|
+
export default function preprocessContent({ fileContent: initialFileContent, filePath, markdownConfig, admonitions, }: {
|
|
13
|
+
fileContent: string;
|
|
14
|
+
filePath: string;
|
|
15
|
+
markdownConfig: Options['markdownConfig'];
|
|
16
|
+
admonitions: Options['admonitions'] | undefined;
|
|
17
|
+
}): string;
|
|
18
|
+
//# sourceMappingURL=preprocessor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preprocessor.d.ts","sourceRoot":"","sources":["../src/preprocessor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAEvC;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,WAAW,EAAE,kBAAkB,EAC/B,QAAQ,EACR,cAAc,EACd,WAAW,GACZ,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC1C,WAAW,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,SAAS,CAAC;CACjD,GAAG,MAAM,CAiBT"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.default = preprocessContent;
|
|
10
|
+
const utils_1 = require("@docusaurus/utils");
|
|
11
|
+
const admonitions_1 = require("./remark/admonitions");
|
|
12
|
+
/**
|
|
13
|
+
* Preprocess the string before passing it to MDX
|
|
14
|
+
* This is not particularly recommended but makes it easier to upgrade to MDX 2
|
|
15
|
+
*/
|
|
16
|
+
function preprocessContent({ fileContent: initialFileContent, filePath, markdownConfig, admonitions, }) {
|
|
17
|
+
let fileContent = initialFileContent;
|
|
18
|
+
if (markdownConfig.preprocessor) {
|
|
19
|
+
fileContent = markdownConfig.preprocessor({
|
|
20
|
+
fileContent,
|
|
21
|
+
filePath,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
fileContent = (0, utils_1.unwrapMdxCodeBlocks)(fileContent);
|
|
25
|
+
if (markdownConfig.mdx1Compat.headingIds) {
|
|
26
|
+
fileContent = (0, utils_1.escapeMarkdownHeadingIds)(fileContent);
|
|
27
|
+
}
|
|
28
|
+
if (markdownConfig.mdx1Compat.admonitions && admonitions) {
|
|
29
|
+
const { keywords } = (0, admonitions_1.normalizeAdmonitionOptions)(admonitions);
|
|
30
|
+
fileContent = (0, utils_1.admonitionTitleToDirectiveLabel)(fileContent, keywords);
|
|
31
|
+
}
|
|
32
|
+
return fileContent;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=preprocessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preprocessor.js","sourceRoot":"","sources":["../src/preprocessor.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,6CAI2B;AAC3B,sDAAgE;AAGhE;;;GAGG;AACH,2BAA0C,EACxC,WAAW,EAAE,kBAAkB,EAC/B,QAAQ,EACR,cAAc,EACd,WAAW,GAMZ;IACC,IAAI,WAAW,GAAG,kBAAkB,CAAC;IACrC,IAAI,cAAc,CAAC,YAAY,EAAE,CAAC;QAChC,WAAW,GAAG,cAAc,CAAC,YAAY,CAAC;YACxC,WAAW;YACX,QAAQ;SACT,CAAC,CAAC;IACL,CAAC;IACD,WAAW,GAAG,IAAA,2BAAmB,EAAC,WAAW,CAAC,CAAC;IAC/C,IAAI,cAAc,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC;QACzC,WAAW,GAAG,IAAA,gCAAwB,EAAC,WAAW,CAAC,CAAC;IACtD,CAAC;IACD,IAAI,cAAc,CAAC,UAAU,CAAC,WAAW,IAAI,WAAW,EAAE,CAAC;QACzD,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAA,wCAA0B,EAAC,WAAW,CAAC,CAAC;QAC3D,WAAW,GAAG,IAAA,uCAA+B,EAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC"}
|