@astrojs/mdx 4.1.1 → 4.2.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/dist/index.js +2 -1
- package/dist/plugins.d.ts +1 -0
- package/dist/plugins.js +14 -8
- package/dist/vite-plugin-mdx.d.ts +1 -0
- package/dist/vite-plugin-mdx.js +4 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -58,7 +58,8 @@ function mdx(partialMdxOptions = {}) {
|
|
|
58
58
|
});
|
|
59
59
|
Object.assign(vitePluginMdxOptions, {
|
|
60
60
|
mdxOptions: resolvedMdxOptions,
|
|
61
|
-
srcDir: config.srcDir
|
|
61
|
+
srcDir: config.srcDir,
|
|
62
|
+
experimentalHeadingIdCompat: config.experimental.headingIdCompat
|
|
62
63
|
});
|
|
63
64
|
vitePluginMdxOptions = {};
|
|
64
65
|
}
|
package/dist/plugins.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { MdxOptions } from './index.js';
|
|
2
2
|
interface MdxProcessorExtraOptions {
|
|
3
3
|
sourcemap: boolean;
|
|
4
|
+
experimentalHeadingIdCompat: boolean;
|
|
4
5
|
}
|
|
5
6
|
export declare function createMdxProcessor(mdxOptions: MdxOptions, extraOptions: MdxProcessorExtraOptions): import("unified").Processor<import("mdast").Root, import("estree").Program, import("estree").Program, import("estree").Program, string>;
|
|
6
7
|
export {};
|
package/dist/plugins.js
CHANGED
|
@@ -19,7 +19,7 @@ const isPerformanceBenchmark = Boolean(process.env.ASTRO_PERFORMANCE_BENCHMARK);
|
|
|
19
19
|
function createMdxProcessor(mdxOptions, extraOptions) {
|
|
20
20
|
return createProcessor({
|
|
21
21
|
remarkPlugins: getRemarkPlugins(mdxOptions),
|
|
22
|
-
rehypePlugins: getRehypePlugins(mdxOptions),
|
|
22
|
+
rehypePlugins: getRehypePlugins(mdxOptions, extraOptions),
|
|
23
23
|
recmaPlugins: mdxOptions.recmaPlugins,
|
|
24
24
|
remarkRehypeOptions: mdxOptions.remarkRehype,
|
|
25
25
|
jsxImportSource: "astro",
|
|
@@ -43,23 +43,29 @@ function getRemarkPlugins(mdxOptions) {
|
|
|
43
43
|
remarkPlugins.push(...mdxOptions.remarkPlugins, remarkCollectImages);
|
|
44
44
|
return remarkPlugins;
|
|
45
45
|
}
|
|
46
|
-
function getRehypePlugins(mdxOptions) {
|
|
46
|
+
function getRehypePlugins(mdxOptions, { experimentalHeadingIdCompat }) {
|
|
47
47
|
let rehypePlugins = [
|
|
48
48
|
// ensure `data.meta` is preserved in `properties.metastring` for rehype syntax highlighters
|
|
49
49
|
rehypeMetaString,
|
|
50
50
|
// rehypeRaw allows custom syntax highlighters to work without added config
|
|
51
51
|
[rehypeRaw, { passThrough: nodeTypes }]
|
|
52
52
|
];
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
const syntaxHighlight = mdxOptions.syntaxHighlight;
|
|
54
|
+
if (syntaxHighlight && !isPerformanceBenchmark) {
|
|
55
|
+
const syntaxHighlightType = typeof syntaxHighlight === "string" ? syntaxHighlight : syntaxHighlight?.type;
|
|
56
|
+
const excludeLangs = typeof syntaxHighlight === "object" ? syntaxHighlight?.excludeLangs : void 0;
|
|
57
|
+
if (syntaxHighlightType === "shiki") {
|
|
58
|
+
rehypePlugins.push([rehypeShiki, mdxOptions.shikiConfig, excludeLangs]);
|
|
59
|
+
} else if (syntaxHighlightType === "prism") {
|
|
60
|
+
rehypePlugins.push([rehypePrism, excludeLangs]);
|
|
58
61
|
}
|
|
59
62
|
}
|
|
60
63
|
rehypePlugins.push(...mdxOptions.rehypePlugins, rehypeImageToComponent);
|
|
61
64
|
if (!isPerformanceBenchmark) {
|
|
62
|
-
rehypePlugins.push(
|
|
65
|
+
rehypePlugins.push(
|
|
66
|
+
[rehypeHeadingIds, { experimentalHeadingIdCompat }],
|
|
67
|
+
rehypeInjectHeadingsExport
|
|
68
|
+
);
|
|
63
69
|
}
|
|
64
70
|
rehypePlugins.push(
|
|
65
71
|
// Render info from `vfile.data.astro.frontmatter` as JS
|
package/dist/vite-plugin-mdx.js
CHANGED
|
@@ -43,7 +43,10 @@ function vitePluginMdx(opts) {
|
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
45
|
if (!processor) {
|
|
46
|
-
processor = createMdxProcessor(opts.mdxOptions, {
|
|
46
|
+
processor = createMdxProcessor(opts.mdxOptions, {
|
|
47
|
+
sourcemap: sourcemapEnabled,
|
|
48
|
+
experimentalHeadingIdCompat: opts.experimentalHeadingIdCompat
|
|
49
|
+
});
|
|
47
50
|
}
|
|
48
51
|
try {
|
|
49
52
|
const compiled = await processor.process(vfile);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/mdx",
|
|
3
3
|
"description": "Add support for MDX pages in your Astro site",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"author": "withastro",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@mdx-js/mdx": "^3.1.0",
|
|
32
|
-
"acorn": "^8.14.
|
|
32
|
+
"acorn": "^8.14.1",
|
|
33
33
|
"es-module-lexer": "^1.6.0",
|
|
34
34
|
"estree-util-visit": "^2.0.0",
|
|
35
35
|
"hast-util-to-html": "^9.0.5",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"source-map": "^0.7.4",
|
|
41
41
|
"unist-util-visit": "^5.0.0",
|
|
42
42
|
"vfile": "^6.0.3",
|
|
43
|
-
"@astrojs/markdown-remark": "6.
|
|
43
|
+
"@astrojs/markdown-remark": "6.3.0"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"astro": "^5.0.0"
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"remark-toc": "^9.0.0",
|
|
63
63
|
"shiki": "^1.29.2",
|
|
64
64
|
"unified": "^11.0.5",
|
|
65
|
-
"vite": "^6.2.
|
|
66
|
-
"astro": "5.
|
|
65
|
+
"vite": "^6.2.1",
|
|
66
|
+
"astro": "5.5.0",
|
|
67
67
|
"astro-scripts": "0.0.14"
|
|
68
68
|
},
|
|
69
69
|
"engines": {
|