@studiocms/mdx 0.1.0-beta.25 → 0.1.0-beta.27
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/README.md +2 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +33 -21
- package/dist/lib/shared.d.ts +1 -1
- package/dist/lib/shared.js +2 -2
- package/package.json +8 -7
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,18 @@
|
|
|
4
4
|
* directives must be first at the top of the file and can only be preceded by this comment.
|
|
5
5
|
*/
|
|
6
6
|
/// <reference types="./virtual.d.ts" preserve="true" />
|
|
7
|
+
import type { AstroIntegration } from 'astro';
|
|
7
8
|
import { type StudioCMSPlugin } from 'studiocms/plugins';
|
|
8
9
|
import type { MDXPluginOptions } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Creates an internal Astro integration for MDX functionality.
|
|
12
|
+
* This is used by the StudioCMS plugin and can be used directly in tests.
|
|
13
|
+
*
|
|
14
|
+
* @param {string} packageIdentifier - The package identifier for the integration.
|
|
15
|
+
* @param {MDXPluginOptions} [options] - Optional configuration options for the MDX plugin.
|
|
16
|
+
* @returns {AstroIntegration} The configured Astro integration.
|
|
17
|
+
*/
|
|
18
|
+
export declare function internalMDXIntegration(packageIdentifier: string, options?: MDXPluginOptions): AstroIntegration;
|
|
9
19
|
/**
|
|
10
20
|
* Creates and configures the StudioCMS MDX plugin.
|
|
11
21
|
*
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
import { addVirtualImports, createResolver } from "astro-integration-kit";
|
|
2
2
|
import { definePlugin } from "studiocms/plugins";
|
|
3
3
|
import { shared } from "./lib/shared.js";
|
|
4
|
+
function internalMDXIntegration(packageIdentifier, options) {
|
|
5
|
+
const { resolve } = createResolver(import.meta.url);
|
|
6
|
+
const internalRenderer = resolve("./lib/render.js");
|
|
7
|
+
const resolvedOptions = {
|
|
8
|
+
remarkPlugins: options?.remarkPlugins || [],
|
|
9
|
+
rehypePlugins: options?.rehypePlugins || [],
|
|
10
|
+
recmaPlugins: options?.recmaPlugins || [],
|
|
11
|
+
remarkRehypeOptions: options?.remarkRehypeOptions || {}
|
|
12
|
+
};
|
|
13
|
+
return {
|
|
14
|
+
name: packageIdentifier,
|
|
15
|
+
hooks: {
|
|
16
|
+
"astro:config:setup": (params) => {
|
|
17
|
+
addVirtualImports(params, {
|
|
18
|
+
name: packageIdentifier,
|
|
19
|
+
imports: {
|
|
20
|
+
"studiocms:mdx/renderer": `
|
|
21
|
+
import { renderMDX as _render } from '${internalRenderer}';
|
|
22
|
+
|
|
23
|
+
export const renderMDX = _render;
|
|
24
|
+
export default renderMDX;
|
|
25
|
+
`
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
"astro:config:done": () => {
|
|
30
|
+
shared.mdxConfig = resolvedOptions;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
4
35
|
function studiocmsMDX(options) {
|
|
5
36
|
const { resolve } = createResolver(import.meta.url);
|
|
6
37
|
const packageIdentifier = "@studiocms/mdx";
|
|
@@ -20,27 +51,7 @@ function studiocmsMDX(options) {
|
|
|
20
51
|
requires: ["@studiocms/md"],
|
|
21
52
|
hooks: {
|
|
22
53
|
"studiocms:astro:config": ({ addIntegrations }) => {
|
|
23
|
-
addIntegrations(
|
|
24
|
-
name: packageIdentifier,
|
|
25
|
-
hooks: {
|
|
26
|
-
"astro:config:setup": (params) => {
|
|
27
|
-
addVirtualImports(params, {
|
|
28
|
-
name: packageIdentifier,
|
|
29
|
-
imports: {
|
|
30
|
-
"studiocms:mdx/renderer": `
|
|
31
|
-
import { renderMDX as _render } from '${internalRenderer}';
|
|
32
|
-
|
|
33
|
-
export const renderMDX = _render;
|
|
34
|
-
export default renderMDX;
|
|
35
|
-
`
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
},
|
|
39
|
-
"astro:config:done": () => {
|
|
40
|
-
shared.mdxConfig = resolvedOptions;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
});
|
|
54
|
+
addIntegrations(internalMDXIntegration(packageIdentifier, resolvedOptions));
|
|
44
55
|
},
|
|
45
56
|
"studiocms:config:setup": ({ setRendering }) => {
|
|
46
57
|
setRendering({
|
|
@@ -61,5 +72,6 @@ function studiocmsMDX(options) {
|
|
|
61
72
|
var index_default = studiocmsMDX;
|
|
62
73
|
export {
|
|
63
74
|
index_default as default,
|
|
75
|
+
internalMDXIntegration,
|
|
64
76
|
studiocmsMDX
|
|
65
77
|
};
|
package/dist/lib/shared.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const symbol: symbol;
|
|
|
5
5
|
* initialized as a new object with a `mdxConfig` property.
|
|
6
6
|
*
|
|
7
7
|
* @remarks
|
|
8
|
-
* The `@ts-
|
|
8
|
+
* The `@ts-expect-error` comments are used to suppress TypeScript errors related to the use of
|
|
9
9
|
* the global scope and assignment within expressions. The `biome-ignore` comment is used
|
|
10
10
|
* to suppress linting errors for the same reason.
|
|
11
11
|
*/
|
package/dist/lib/shared.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const symbol = Symbol.for("@studiocms/mdx");
|
|
2
2
|
const shared = (
|
|
3
|
-
// @ts-
|
|
4
|
-
globalThis[symbol] || // @ts-
|
|
3
|
+
// @ts-expect-error
|
|
4
|
+
globalThis[symbol] || // @ts-expect-error
|
|
5
5
|
// biome-ignore lint/suspicious/noAssignInExpressions: this is a valid use case for assignment in expressions.
|
|
6
6
|
(globalThis[symbol] = {
|
|
7
7
|
mdxConfig: {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studiocms/mdx",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.27",
|
|
4
4
|
"description": "Add MDX Support to your StudioCMS project with ease!",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "withstudiocms",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"type": "module",
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@mdx-js/mdx": "^3.1.
|
|
58
|
+
"@mdx-js/mdx": "^3.1.1",
|
|
59
59
|
"astro-integration-kit": "^0.19.0",
|
|
60
60
|
"react": "^19.1.1",
|
|
61
61
|
"react-dom": "^19.1.1",
|
|
@@ -65,19 +65,20 @@
|
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@types/node": "^22.0.0",
|
|
68
|
-
"@types/react": "^19.1.
|
|
69
|
-
"@types/react-dom": "^19.1.
|
|
68
|
+
"@types/react": "^19.1.13",
|
|
69
|
+
"@types/react-dom": "^19.1.9"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"astro": "^5.12.9",
|
|
73
|
-
"effect": "^3.17.
|
|
73
|
+
"effect": "^3.17.14",
|
|
74
74
|
"vite": "^6.3.4",
|
|
75
|
-
"@studiocms/md": "0.1.0-beta.
|
|
76
|
-
"studiocms": "0.1.0-beta.
|
|
75
|
+
"@studiocms/md": "0.1.0-beta.27",
|
|
76
|
+
"studiocms": "0.1.0-beta.27"
|
|
77
77
|
},
|
|
78
78
|
"scripts": {
|
|
79
79
|
"build": "buildkit build 'src/**/*.{ts,astro,css,json,png,d.ts}'",
|
|
80
80
|
"dev": "buildkit dev 'src/**/*.{ts,astro,css,json,png,d.ts}'",
|
|
81
|
+
"test": "vitest",
|
|
81
82
|
"typecheck": "tspc -p tsconfig.tspc.json"
|
|
82
83
|
}
|
|
83
84
|
}
|