@astrojs/mdx 3.0.1 → 3.1.1
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.d.ts +2 -1
- package/dist/index.js +14 -6
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +5 -5
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { markdownConfigDefaults } from '@astrojs/markdown-remark';
|
|
2
|
-
import type { AstroIntegration } from 'astro';
|
|
2
|
+
import type { AstroIntegration, ContainerRenderer } from 'astro';
|
|
3
3
|
import type { Options as RemarkRehypeOptions } from 'remark-rehype';
|
|
4
4
|
import type { PluggableList } from 'unified';
|
|
5
5
|
import type { OptimizeOptions } from './rehype-optimize-static.js';
|
|
@@ -11,4 +11,5 @@ export type MdxOptions = Omit<typeof markdownConfigDefaults, 'remarkPlugins' | '
|
|
|
11
11
|
remarkRehype: RemarkRehypeOptions;
|
|
12
12
|
optimize: boolean | OptimizeOptions;
|
|
13
13
|
};
|
|
14
|
+
export declare function getContainerRenderer(): ContainerRenderer;
|
|
14
15
|
export default function mdx(partialMdxOptions?: Partial<MdxOptions>): AstroIntegration;
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,12 @@ import astroJSXRenderer from "astro/jsx/renderer.js";
|
|
|
5
5
|
import { ignoreStringPlugins, parseFrontmatter } from "./utils.js";
|
|
6
6
|
import { vitePluginMdxPostprocess } from "./vite-plugin-mdx-postprocess.js";
|
|
7
7
|
import { vitePluginMdx } from "./vite-plugin-mdx.js";
|
|
8
|
+
function getContainerRenderer() {
|
|
9
|
+
return {
|
|
10
|
+
name: "astro:jsx",
|
|
11
|
+
serverEntrypoint: "astro/jsx/server.js"
|
|
12
|
+
};
|
|
13
|
+
}
|
|
8
14
|
function mdx(partialMdxOptions = {}) {
|
|
9
15
|
let mdxOptions = {};
|
|
10
16
|
return {
|
|
@@ -39,12 +45,13 @@ function mdx(partialMdxOptions = {}) {
|
|
|
39
45
|
}
|
|
40
46
|
});
|
|
41
47
|
},
|
|
42
|
-
"astro:config:done": ({ config }) => {
|
|
48
|
+
"astro:config:done": ({ config, logger }) => {
|
|
43
49
|
const extendMarkdownConfig = partialMdxOptions.extendMarkdownConfig ?? defaultMdxOptions.extendMarkdownConfig;
|
|
44
50
|
const resolvedMdxOptions = applyDefaultOptions({
|
|
45
51
|
options: partialMdxOptions,
|
|
46
52
|
defaults: markdownConfigToMdxOptions(
|
|
47
|
-
extendMarkdownConfig ? config.markdown : markdownConfigDefaults
|
|
53
|
+
extendMarkdownConfig ? config.markdown : markdownConfigDefaults,
|
|
54
|
+
logger
|
|
48
55
|
)
|
|
49
56
|
});
|
|
50
57
|
Object.assign(mdxOptions, resolvedMdxOptions);
|
|
@@ -58,12 +65,12 @@ const defaultMdxOptions = {
|
|
|
58
65
|
recmaPlugins: [],
|
|
59
66
|
optimize: false
|
|
60
67
|
};
|
|
61
|
-
function markdownConfigToMdxOptions(markdownConfig) {
|
|
68
|
+
function markdownConfigToMdxOptions(markdownConfig, logger) {
|
|
62
69
|
return {
|
|
63
70
|
...defaultMdxOptions,
|
|
64
71
|
...markdownConfig,
|
|
65
|
-
remarkPlugins: ignoreStringPlugins(markdownConfig.remarkPlugins),
|
|
66
|
-
rehypePlugins: ignoreStringPlugins(markdownConfig.rehypePlugins),
|
|
72
|
+
remarkPlugins: ignoreStringPlugins(markdownConfig.remarkPlugins, logger),
|
|
73
|
+
rehypePlugins: ignoreStringPlugins(markdownConfig.rehypePlugins, logger),
|
|
67
74
|
remarkRehype: markdownConfig.remarkRehype ?? {}
|
|
68
75
|
};
|
|
69
76
|
}
|
|
@@ -85,5 +92,6 @@ function applyDefaultOptions({
|
|
|
85
92
|
};
|
|
86
93
|
}
|
|
87
94
|
export {
|
|
88
|
-
mdx as default
|
|
95
|
+
mdx as default,
|
|
96
|
+
getContainerRenderer
|
|
89
97
|
};
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Options as AcornOpts } from 'acorn';
|
|
2
|
-
import type { AstroConfig } from 'astro';
|
|
2
|
+
import type { AstroConfig, AstroIntegrationLogger } from 'astro';
|
|
3
3
|
import matter from 'gray-matter';
|
|
4
4
|
import type { MdxjsEsm } from 'mdast-util-mdx';
|
|
5
5
|
import type { PluggableList } from 'unified';
|
|
@@ -15,4 +15,4 @@ export declare function getFileInfo(id: string, config: AstroConfig): FileInfo;
|
|
|
15
15
|
*/
|
|
16
16
|
export declare function parseFrontmatter(code: string, id: string): matter.GrayMatterFile<string>;
|
|
17
17
|
export declare function jsToTreeNode(jsString: string, acornOpts?: AcornOpts): MdxjsEsm;
|
|
18
|
-
export declare function ignoreStringPlugins(plugins: any[]): PluggableList;
|
|
18
|
+
export declare function ignoreStringPlugins(plugins: any[], logger: AstroIntegrationLogger): PluggableList;
|
package/dist/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parse } from "acorn";
|
|
2
2
|
import matter from "gray-matter";
|
|
3
|
-
import { bold
|
|
3
|
+
import { bold } from "kleur/colors";
|
|
4
4
|
function appendForwardSlash(path) {
|
|
5
5
|
return path.endsWith("/") ? path : path + "/";
|
|
6
6
|
}
|
|
@@ -60,22 +60,22 @@ function jsToTreeNode(jsString, acornOpts = {
|
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
-
function ignoreStringPlugins(plugins) {
|
|
63
|
+
function ignoreStringPlugins(plugins, logger) {
|
|
64
64
|
let validPlugins = [];
|
|
65
65
|
let hasInvalidPlugin = false;
|
|
66
66
|
for (const plugin of plugins) {
|
|
67
67
|
if (typeof plugin === "string") {
|
|
68
|
-
|
|
68
|
+
logger.warn(`${bold(plugin)} not applied.`);
|
|
69
69
|
hasInvalidPlugin = true;
|
|
70
70
|
} else if (Array.isArray(plugin) && typeof plugin[0] === "string") {
|
|
71
|
-
|
|
71
|
+
logger.warn(`${bold(plugin[0])} not applied.`);
|
|
72
72
|
hasInvalidPlugin = true;
|
|
73
73
|
} else {
|
|
74
74
|
validPlugins.push(plugin);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
if (hasInvalidPlugin) {
|
|
78
|
-
|
|
78
|
+
logger.warn(
|
|
79
79
|
`To inherit Markdown plugins in MDX, please use explicit imports in your config instead of "strings." See Markdown docs: https://docs.astro.build/en/guides/markdown-content/#markdown-plugins`
|
|
80
80
|
);
|
|
81
81
|
}
|
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": "3.
|
|
4
|
+
"version": "3.1.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"author": "withastro",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@mdx-js/mdx": "^3.0.1",
|
|
31
|
-
"acorn": "^8.
|
|
32
|
-
"es-module-lexer": "^1.5.
|
|
31
|
+
"acorn": "^8.12.0",
|
|
32
|
+
"es-module-lexer": "^1.5.3",
|
|
33
33
|
"estree-util-visit": "^2.0.0",
|
|
34
34
|
"github-slugger": "^2.0.0",
|
|
35
35
|
"gray-matter": "^4.0.3",
|
|
@@ -49,23 +49,23 @@
|
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/estree": "^1.0.5",
|
|
51
51
|
"@types/hast": "^3.0.4",
|
|
52
|
-
"@types/mdast": "^4.0.
|
|
52
|
+
"@types/mdast": "^4.0.4",
|
|
53
53
|
"@types/yargs-parser": "^21.0.3",
|
|
54
54
|
"cheerio": "1.0.0-rc.12",
|
|
55
|
-
"linkedom": "^0.18.
|
|
55
|
+
"linkedom": "^0.18.3",
|
|
56
56
|
"mdast-util-mdx": "^3.0.0",
|
|
57
57
|
"mdast-util-mdx-jsx": "^3.1.2",
|
|
58
58
|
"mdast-util-to-string": "^4.0.0",
|
|
59
59
|
"reading-time": "^1.5.0",
|
|
60
60
|
"rehype-mathjax": "^6.0.0",
|
|
61
|
-
"rehype-pretty-code": "^0.13.
|
|
61
|
+
"rehype-pretty-code": "^0.13.2",
|
|
62
62
|
"remark-math": "^6.0.0",
|
|
63
63
|
"remark-rehype": "^11.1.0",
|
|
64
64
|
"remark-shiki-twoslash": "^3.1.3",
|
|
65
65
|
"remark-toc": "^9.0.0",
|
|
66
66
|
"unified": "^11.0.4",
|
|
67
|
-
"vite": "^5.
|
|
68
|
-
"astro": "4.
|
|
67
|
+
"vite": "^5.3.1",
|
|
68
|
+
"astro": "4.10.3",
|
|
69
69
|
"astro-scripts": "0.0.14"
|
|
70
70
|
},
|
|
71
71
|
"engines": {
|