You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+43-68Lines changed: 43 additions & 68 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@
28
28
29
29
# Mintlify's markdown parser
30
30
31
-
**@mintlify/mdx** is a thin layer on top of [next-mdx-remote](https://github.com/hashicorp/next-mdx-remote) that provides a better developer experience for Next.js users by adding support for syntax highlighting.
31
+
**@mintlify/mdx** is a thin layer on top of [next-mdx-remote-client](https://github.com/ipikuka/next-mdx-remote-client) that provides a better developer experience for Next.js users by adding support for syntax highlighting.
32
32
33
33
## Installation
34
34
@@ -49,29 +49,29 @@ pnpm add @mintlify/mdx
49
49
50
50
[You can check the example app here](https://github.com/mintlify/mdx/tree/main/examples/pages-router).
51
51
52
-
1. Call the `getCompiledMdx` function inside `getStaticProps` and return the `mdxSource` object.
52
+
1. Call the `serialize` function inside `getStaticProps` and return the `mdxSource` object.
53
53
54
54
```tsx
55
55
exportconst getStaticProps = (async () => {
56
-
const mdxSource =awaitgetCompiledMdx({
56
+
const mdxSource =awaitserialize({
57
57
source: '## Markdown H2',
58
58
});
59
59
60
-
return {
61
-
props: {
62
-
mdxSource,
63
-
},
64
-
};
60
+
if ('error'inmdxSource) {
61
+
// handle error case
62
+
}
63
+
64
+
return { props: { mdxSource } };
65
65
}) satisfiesGetStaticProps<{
66
-
mdxSource:MDXCompiledResult;
66
+
mdxSource:SerializeSuccess;
67
67
}>;
68
68
```
69
69
70
70
2. Pass the `mdxSource` object as props inside the `MDXComponent`.
Similar to [next-mdx-remote](https://github.com/hashicorp/next-mdx-remote), this package exports the following APIs:
136
+
Similar to [next-mdx-remote-client](https://github.com/ipikuka/next-mdx-remote-client), this package exports the following APIs:
141
137
142
-
-`getCompiledMdx` - a function that compiles MDX source to MDXCompiledResult.
143
-
-`MDXComponent` - a component that renders MDXCompiledResult.
144
-
-`getCompiledServerMdx` - a function that compiles MDX source to return `content` and `frontmatter ` and should be used inside async React Server Component.
145
-
-`MDXServerComponent` - a component that renders `content` and `frontmatter ` and should be used inside async React Server Component.
138
+
-`serialize` - a function that compiles MDX source to SerializeResult.
139
+
-`MDXClient` - a component that renders SerializeSuccess on the client.
140
+
-`MDXRemote` - a component that both serializes and renders the source - should be used inside async React Server Component.
0 commit comments