@astrojs/mdx 2.0.6 → 2.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/plugins.js CHANGED
@@ -32,7 +32,7 @@ function createMdxProcessor(mdxOptions, extraOptions) {
32
32
  });
33
33
  }
34
34
  function getRemarkPlugins(mdxOptions) {
35
- let remarkPlugins = [remarkCollectImages, remarkImageToComponent];
35
+ let remarkPlugins = [];
36
36
  if (!isPerformanceBenchmark) {
37
37
  if (mdxOptions.gfm) {
38
38
  remarkPlugins.push(remarkGfm);
@@ -41,7 +41,12 @@ function getRemarkPlugins(mdxOptions) {
41
41
  remarkPlugins.push(remarkSmartypants);
42
42
  }
43
43
  }
44
- remarkPlugins = [...remarkPlugins, ...mdxOptions.remarkPlugins];
44
+ remarkPlugins = [
45
+ ...remarkPlugins,
46
+ ...mdxOptions.remarkPlugins,
47
+ remarkCollectImages,
48
+ remarkImageToComponent
49
+ ];
45
50
  if (!isPerformanceBenchmark) {
46
51
  if (mdxOptions.syntaxHighlight === "shiki") {
47
52
  remarkPlugins.push([remarkShiki, mdxOptions.shikiConfig]);
@@ -74,6 +74,51 @@ function remarkImageToComponent() {
74
74
  value: node.title
75
75
  });
76
76
  }
77
+ if (node.data && node.data.hProperties) {
78
+ const createArrayAttribute = (name, values) => {
79
+ return {
80
+ type: "mdxJsxAttribute",
81
+ name,
82
+ value: {
83
+ type: "mdxJsxAttributeValueExpression",
84
+ value: name,
85
+ data: {
86
+ estree: {
87
+ type: "Program",
88
+ body: [
89
+ {
90
+ type: "ExpressionStatement",
91
+ expression: {
92
+ type: "ArrayExpression",
93
+ elements: values.map((value) => ({
94
+ type: "Literal",
95
+ value,
96
+ raw: String(value)
97
+ }))
98
+ }
99
+ }
100
+ ],
101
+ sourceType: "module",
102
+ comments: []
103
+ }
104
+ }
105
+ }
106
+ };
107
+ };
108
+ Object.entries(node.data.hProperties).forEach(
109
+ ([key, value]) => {
110
+ if (Array.isArray(value)) {
111
+ componentElement.attributes.push(createArrayAttribute(key, value));
112
+ } else {
113
+ componentElement.attributes.push({
114
+ name: key,
115
+ type: "mdxJsxAttribute",
116
+ value: String(value)
117
+ });
118
+ }
119
+ }
120
+ );
121
+ }
77
122
  parent.children.splice(index, 1, componentElement);
78
123
  }
79
124
  });
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.0.6",
4
+ "version": "2.1.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": "4.2.0"
44
+ "@astrojs/markdown-remark": "4.2.1"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "astro": "^4.0.0"
@@ -66,8 +66,8 @@
66
66
  "remark-shiki-twoslash": "^3.1.3",
67
67
  "remark-toc": "^9.0.0",
68
68
  "unified": "^11.0.4",
69
- "vite": "^5.0.10",
70
- "astro": "4.2.2",
69
+ "vite": "^5.0.12",
70
+ "astro": "4.2.7",
71
71
  "astro-scripts": "0.0.14"
72
72
  },
73
73
  "engines": {