@astrojs/mdx 3.1.0 → 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.js +6 -5
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +5 -5
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -45,12 +45,13 @@ function mdx(partialMdxOptions = {}) {
|
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
},
|
|
48
|
-
"astro:config:done": ({ config }) => {
|
|
48
|
+
"astro:config:done": ({ config, logger }) => {
|
|
49
49
|
const extendMarkdownConfig = partialMdxOptions.extendMarkdownConfig ?? defaultMdxOptions.extendMarkdownConfig;
|
|
50
50
|
const resolvedMdxOptions = applyDefaultOptions({
|
|
51
51
|
options: partialMdxOptions,
|
|
52
52
|
defaults: markdownConfigToMdxOptions(
|
|
53
|
-
extendMarkdownConfig ? config.markdown : markdownConfigDefaults
|
|
53
|
+
extendMarkdownConfig ? config.markdown : markdownConfigDefaults,
|
|
54
|
+
logger
|
|
54
55
|
)
|
|
55
56
|
});
|
|
56
57
|
Object.assign(mdxOptions, resolvedMdxOptions);
|
|
@@ -64,12 +65,12 @@ const defaultMdxOptions = {
|
|
|
64
65
|
recmaPlugins: [],
|
|
65
66
|
optimize: false
|
|
66
67
|
};
|
|
67
|
-
function markdownConfigToMdxOptions(markdownConfig) {
|
|
68
|
+
function markdownConfigToMdxOptions(markdownConfig, logger) {
|
|
68
69
|
return {
|
|
69
70
|
...defaultMdxOptions,
|
|
70
71
|
...markdownConfig,
|
|
71
|
-
remarkPlugins: ignoreStringPlugins(markdownConfig.remarkPlugins),
|
|
72
|
-
rehypePlugins: ignoreStringPlugins(markdownConfig.rehypePlugins),
|
|
72
|
+
remarkPlugins: ignoreStringPlugins(markdownConfig.remarkPlugins, logger),
|
|
73
|
+
rehypePlugins: ignoreStringPlugins(markdownConfig.rehypePlugins, logger),
|
|
73
74
|
remarkRehype: markdownConfig.remarkRehype ?? {}
|
|
74
75
|
};
|
|
75
76
|
}
|
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.1.
|
|
4
|
+
"version": "3.1.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"author": "withastro",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@mdx-js/mdx": "^3.0.1",
|
|
31
|
-
"acorn": "^8.
|
|
31
|
+
"acorn": "^8.12.0",
|
|
32
32
|
"es-module-lexer": "^1.5.3",
|
|
33
33
|
"estree-util-visit": "^2.0.0",
|
|
34
34
|
"github-slugger": "^2.0.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
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",
|
|
@@ -64,8 +64,8 @@
|
|
|
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.10.
|
|
67
|
+
"vite": "^5.3.1",
|
|
68
|
+
"astro": "4.10.3",
|
|
69
69
|
"astro-scripts": "0.0.14"
|
|
70
70
|
},
|
|
71
71
|
"engines": {
|