@ecopages/mdx 0.2.0-alpha.12 → 0.2.0-alpha.14

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/CHANGELOG.md CHANGED
@@ -8,23 +8,18 @@ All notable changes to `@ecopages/mdx` are documented here.
8
8
 
9
9
  ### Features
10
10
 
11
- - Added standalone MDX server rendering and async compilation support.
11
+ - Added standalone non-React MDX server rendering with async compilation and opt-in `.md` support.
12
12
 
13
13
  ### Bug Fixes
14
14
 
15
- - Fixed `.md` opt-in handling, loader registration, and Node `source-map` interop.
16
-
17
- ### Refactoring
18
-
19
- - Removed the React-specific renderer and HMR path from the package.
15
+ - Fixed loader registration, Node `source-map` interop, and renderer-owned mixed-boundary rendering for standalone MDX routes.
20
16
 
21
17
  ### Documentation
22
18
 
23
- - Updated the README for standalone MDX registration and the current integration setup.
19
+ - Updated the README for standalone non-React MDX usage, `.md` opt-in handling, and compiler configuration.
24
20
 
25
21
  ---
26
22
 
27
23
  ## Migration Notes
28
24
 
29
- - Register `@ecopages/mdx` and `@ecopages/react` separately when you want MDX server rendering together with React client hydration.
30
- - The previous React-specific MDX path, including `useReact` and the React-specific HMR hooks, has been removed.
25
+ - Use `reactPlugin({ mdx: { enabled: true } })` for React-backed MDX routes; the standalone `@ecopages/mdx` plugin now targets non-React JSX runtimes.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @ecopages/mdx
2
2
 
3
- Integration plugin for standalone MDX support in Ecopages, specifically designed for non-React JSX runtimes (such as `@kitajs/html`). It configures the MDX compiler to process `.mdx` routes natively.
3
+ Integration plugin for standalone MDX support in Ecopages for non-React JSX runtimes such as `@kitajs/html`. Use it when MDX should render directly on the server without React hydration.
4
4
 
5
5
  ## Installation
6
6
 
@@ -29,6 +29,39 @@ By default, the standalone plugin uses:
29
29
  - `jsxImportSource: '@kitajs/html'`
30
30
  - `jsxRuntime: 'automatic'`
31
31
 
32
+ ## What This Integration Owns
33
+
34
+ - `.mdx` route files.
35
+ - Optional `.md` routes when you opt them into `extensions`.
36
+ - MDX compilation against a non-React JSX runtime.
37
+
38
+ ## Configure Markdown Extensions
39
+
40
+ Use `extensions` when both `.mdx` and `.md` files should run through the MDX loader.
41
+
42
+ ```ts
43
+ import { mdxPlugin } from '@ecopages/mdx';
44
+
45
+ mdxPlugin({
46
+ extensions: ['.mdx', '.md'],
47
+ });
48
+ ```
49
+
50
+ ## Compiler Options
51
+
52
+ Pass `compilerOptions` to add remark, rehype, or recma plugins while keeping the non-React JSX runtime managed by the integration.
53
+
54
+ ```ts
55
+ import { mdxPlugin } from '@ecopages/mdx';
56
+
57
+ mdxPlugin({
58
+ compilerOptions: {
59
+ remarkPlugins: [],
60
+ rehypePlugins: [],
61
+ },
62
+ });
63
+ ```
64
+
32
65
  > [!WARNING]
33
66
  > React runtimes are intentionally rejected by this standalone plugin.
34
67
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecopages/mdx",
3
- "version": "0.2.0-alpha.12",
3
+ "version": "0.2.0-alpha.14",
4
4
  "description": "MDX plugin for Ecopages",
5
5
  "keywords": [
6
6
  "ecopages",
@@ -37,7 +37,7 @@
37
37
  "directory": "packages/integrations/mdx"
38
38
  },
39
39
  "peerDependencies": {
40
- "@ecopages/core": "0.2.0-alpha.12",
40
+ "@ecopages/core": "0.2.0-alpha.14",
41
41
  "@kitajs/html": "^4.1.0",
42
42
  "@mdx-js/mdx": "^3.1.0"
43
43
  },
@@ -2,7 +2,7 @@
2
2
  * This module contains the MDX renderer
3
3
  * @module
4
4
  */
5
- import type { EcoComponent, EcoComponentConfig, EcoPageFile, EcoPagesElement, GetMetadata, IntegrationRendererRenderOptions, RouteRendererBody } from '@ecopages/core';
5
+ import type { ComponentRenderInput, ComponentRenderResult, EcoComponent, EcoComponentConfig, EcoPageFile, EcoPagesElement, GetMetadata, IntegrationRendererRenderOptions, RouteRendererBody } from '@ecopages/core';
6
6
  import { IntegrationRenderer, type RenderToResponseContext } from '@ecopages/core/route-renderer/integration-renderer';
7
7
  import type { AssetProcessingService, ProcessedAsset } from '@ecopages/core/services/asset-processing-service';
8
8
  import type { CompileOptions } from '@mdx-js/mdx';
@@ -34,6 +34,11 @@ export declare class MDXRenderer extends IntegrationRenderer<EcoPagesElement> {
34
34
  });
35
35
  buildRouteRenderAssets(pagePath: string): Promise<ProcessedAsset[]>;
36
36
  protected normalizeImportedPageFile<TPageModule extends EcoPageFile>(_file: string, pageModule: TPageModule): TPageModule;
37
+ renderComponent(input: ComponentRenderInput): Promise<ComponentRenderResult>;
38
+ protected createComponentBoundaryRuntime(options: {
39
+ boundaryInput: ComponentRenderInput;
40
+ rendererCache: Map<string, IntegrationRenderer<any>>;
41
+ }): import("@ecopages/core").ComponentBoundaryRuntime;
37
42
  render({ params, query, props, locals, pageLocals, metadata, Page, HtmlTemplate, Layout, pageProps, }: MDXIntegrationRendererOpions): Promise<RouteRendererBody>;
38
43
  renderToResponse<P = Record<string, unknown>>(view: EcoComponent<P>, props: P, ctx: RenderToResponseContext): Promise<Response>;
39
44
  }
@@ -53,6 +53,18 @@ class MDXRenderer extends IntegrationRenderer {
53
53
  invariant(false, `Error importing MDX file: ${error}`);
54
54
  }
55
55
  }
56
+ async renderComponent(input) {
57
+ return this.renderStringComponentBoundaryWithQueuedForeignBoundaries(
58
+ input,
59
+ input.component
60
+ );
61
+ }
62
+ createComponentBoundaryRuntime(options) {
63
+ return this.createQueuedBoundaryRuntime({
64
+ boundaryInput: options.boundaryInput,
65
+ rendererCache: options.rendererCache
66
+ });
67
+ }
56
68
  async render({
57
69
  params,
58
70
  query,
@@ -66,42 +78,31 @@ class MDXRenderer extends IntegrationRenderer {
66
78
  pageProps
67
79
  }) {
68
80
  try {
69
- const pageContent = await Page({ params, query, ...props, locals: pageLocals });
70
- const children = typeof Layout === "function" ? await Layout({ children: pageContent, locals }) : pageContent;
71
- const body = await HtmlTemplate({
81
+ return await this.renderPageWithDocumentShell({
82
+ page: {
83
+ component: Page,
84
+ props: { params, query, ...props, locals: pageLocals }
85
+ },
86
+ layout: Layout ? {
87
+ component: Layout,
88
+ props: locals ? { locals } : {}
89
+ } : void 0,
90
+ htmlTemplate: HtmlTemplate,
72
91
  metadata,
73
- children,
74
92
  pageProps: pageProps || {}
75
93
  });
76
- return this.DOC_TYPE + body;
77
94
  } catch (error) {
78
95
  throw this.createRenderError("Error rendering page", error);
79
96
  }
80
97
  }
81
98
  async renderToResponse(view, props, ctx) {
82
99
  try {
83
- const Layout = view.config?.layout;
84
- const viewFn = view;
85
- const pageContent = await viewFn(props);
86
- let body;
87
- if (ctx.partial) {
88
- body = pageContent;
89
- } else {
90
- const children = Layout ? await Layout({ children: pageContent }) : pageContent;
91
- const HtmlTemplate = await this.getHtmlTemplate();
92
- const metadata = view.metadata ? await view.metadata({
93
- params: {},
94
- query: {},
95
- props,
96
- appConfig: this.appConfig
97
- }) : this.appConfig.defaultMetadata;
98
- body = this.DOC_TYPE + await HtmlTemplate({
99
- metadata,
100
- children,
101
- pageProps: props
102
- });
103
- }
104
- return this.createHtmlResponse(body, ctx);
100
+ return await this.renderViewWithDocumentShell({
101
+ view,
102
+ props,
103
+ ctx,
104
+ layout: view.config?.layout
105
+ });
105
106
  } catch (error) {
106
107
  throw this.createRenderError("Error rendering view", error);
107
108
  }