@astrojs/mdx 2.2.4 → 2.3.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 +16 -0
- package/dist/remark-images-to-component.js +5 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -52,6 +52,9 @@ function mdx(partialMdxOptions = {}) {
|
|
|
52
52
|
{
|
|
53
53
|
name: "@mdx-js/rollup",
|
|
54
54
|
enforce: "pre",
|
|
55
|
+
buildEnd() {
|
|
56
|
+
processor = void 0;
|
|
57
|
+
},
|
|
55
58
|
configResolved(resolved) {
|
|
56
59
|
processor = createMdxProcessor(mdxOptions, {
|
|
57
60
|
sourcemap: !!resolved.build.sourcemap
|
|
@@ -68,6 +71,14 @@ function mdx(partialMdxOptions = {}) {
|
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
73
|
},
|
|
74
|
+
async resolveId(source, importer, options) {
|
|
75
|
+
if (importer?.endsWith(".mdx") && source[0] !== "/") {
|
|
76
|
+
let resolved = await this.resolve(source, importer, options);
|
|
77
|
+
if (!resolved)
|
|
78
|
+
resolved = await this.resolve("./" + source, importer, options);
|
|
79
|
+
return resolved;
|
|
80
|
+
}
|
|
81
|
+
},
|
|
71
82
|
// Override transform to alter code before MDX compilation
|
|
72
83
|
// ex. inject layouts
|
|
73
84
|
async transform(_, id) {
|
|
@@ -78,6 +89,11 @@ function mdx(partialMdxOptions = {}) {
|
|
|
78
89
|
const { data: frontmatter, content: pageContent } = parseFrontmatter(code, id);
|
|
79
90
|
const vfile = new VFile({ value: pageContent, path: id });
|
|
80
91
|
setVfileFrontmatter(vfile, frontmatter);
|
|
92
|
+
if (!processor) {
|
|
93
|
+
return this.error(
|
|
94
|
+
"MDX processor is not initialized. This is an internal error. Please file an issue."
|
|
95
|
+
);
|
|
96
|
+
}
|
|
81
97
|
try {
|
|
82
98
|
const compiled = await processor.process(vfile);
|
|
83
99
|
return {
|
|
@@ -24,7 +24,11 @@ function remarkImageToComponent() {
|
|
|
24
24
|
body: [
|
|
25
25
|
{
|
|
26
26
|
type: "ImportDeclaration",
|
|
27
|
-
source: {
|
|
27
|
+
source: {
|
|
28
|
+
type: "Literal",
|
|
29
|
+
value: node.url,
|
|
30
|
+
raw: JSON.stringify(node.url)
|
|
31
|
+
},
|
|
28
32
|
specifiers: [
|
|
29
33
|
{
|
|
30
34
|
type: "ImportDefaultSpecifier",
|
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": "2.
|
|
4
|
+
"version": "2.3.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"author": "withastro",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"source-map": "^0.7.4",
|
|
42
42
|
"unist-util-visit": "^5.0.0",
|
|
43
43
|
"vfile": "^6.0.1",
|
|
44
|
-
"@astrojs/markdown-remark": "5.
|
|
44
|
+
"@astrojs/markdown-remark": "5.1.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"astro": "^4.0.0"
|
|
@@ -65,11 +65,11 @@
|
|
|
65
65
|
"remark-toc": "^9.0.0",
|
|
66
66
|
"unified": "^11.0.4",
|
|
67
67
|
"vite": "^5.1.4",
|
|
68
|
-
"astro": "4.
|
|
68
|
+
"astro": "4.6.2",
|
|
69
69
|
"astro-scripts": "0.0.14"
|
|
70
70
|
},
|
|
71
71
|
"engines": {
|
|
72
|
-
"node": "
|
|
72
|
+
"node": "^18.17.1 || ^20.3.0 || >=21.0.0"
|
|
73
73
|
},
|
|
74
74
|
"publishConfig": {
|
|
75
75
|
"provenance": true
|