Skip to content

Commit f7d4680

Browse files
authored
Merge pull request #10 from mintlify/ronan/migrate-to-new-package
feat: migrate to new mdx package
2 parents 4eb7618 + de0fc61 commit f7d4680

35 files changed

+7420
-11440
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,12 @@ dist/
1111

1212
# TypeScript
1313
*.tsbuildinfo
14+
15+
# yarn
16+
.pnp.*
17+
.yarn/*
18+
!.yarn/patches
19+
!.yarn/plugins
20+
!.yarn/releases
21+
!.yarn/sdks
22+
!.yarn/versions

.prettierignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
/dist
2-
/node_modules
2+
/node_modules
3+
4+
.next

.yarn/install-state.gz

649 KB
Binary file not shown.

.yarnrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodeLinker: node-modules

examples/app-router/app/page.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1-
import { getCompiledServerMdx } from '@mintlify/mdx';
1+
import { MDXRemote } from '@mintlify/mdx';
22
import { promises as fs } from 'fs';
33

44
export default async function Home() {
5-
const data = await fs.readFile(process.cwd() + '/examples/highlight-example.mdx');
6-
7-
const { content, frontmatter } = await getCompiledServerMdx<{
8-
title: string;
9-
}>({
10-
source: data.toString(),
11-
});
5+
const data = await fs.readFile(process.cwd() + '/examples/highlight-example.mdx', 'utf8');
126

137
return (
148
<article className="prose mx-auto py-8">
15-
<h1>{frontmatter.title}</h1>
16-
{content}
9+
<MDXRemote source={data} parseFrontmatter />
1710
</article>
1811
);
1912
}

examples/app-router/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12-
"@mintlify/mdx": "^0.0.44",
12+
"@mintlify/mdx": "workspace:^",
1313
"next": "14.0.4",
1414
"react": "^18",
1515
"react-dom": "^18"

examples/app-router/readme.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,22 @@ You can check out the demo of [this page](https://github.com/mintlify/mdx/blob/m
1010

1111
## How to use
1212

13-
1. Call the `getCompiledServerMdx` function inside your async React Server Component which will give you the `frontmatter` and `content`.
13+
1. Use the `MDXRemote` component directly inside your async React Server Component.
1414

1515
```tsx
16-
import { getCompiledServerMdx } from '@mintlify/mdx';
16+
import { MDXRemote } from '@mintlify/mdx';
1717

1818
export default async function Home() {
19-
const { content, frontmatter } = await getCompiledServerMdx({
20-
source: `---
21-
title: Title
22-
---
23-
24-
## Markdown H2
25-
`,
26-
});
19+
const source: `---
20+
title: Title
21+
---
22+
23+
## Markdown H2
24+
`;
2725

2826
return (
2927
<article className="prose mx-auto py-8">
30-
<h1>{String(frontmatter.title)}</h1>
31-
32-
{content}
28+
<MDXRemote source={source} parseFrontmatter />
3329
</article>
3430
);
3531
}

0 commit comments

Comments
 (0)