Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,12 @@ dist/

# TypeScript
*.tsbuildinfo

# yarn
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/dist
/node_modules
/node_modules

.next
Binary file added .yarn/install-state.gz
Binary file not shown.
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
13 changes: 3 additions & 10 deletions examples/app-router/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import { getCompiledServerMdx } from '@mintlify/mdx';
import { MDXRemote } from '@mintlify/mdx';
import { promises as fs } from 'fs';

export default async function Home() {
const data = await fs.readFile(process.cwd() + '/examples/highlight-example.mdx');

const { content, frontmatter } = await getCompiledServerMdx<{
title: string;
}>({
source: data.toString(),
});
const data = await fs.readFile(process.cwd() + '/examples/highlight-example.mdx', 'utf8');

return (
<article className="prose mx-auto py-8">
<h1>{frontmatter.title}</h1>
{content}
<MDXRemote source={data} parseFrontmatter />
</article>
);
}
2 changes: 1 addition & 1 deletion examples/app-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"@mintlify/mdx": "^0.0.44",
"@mintlify/mdx": "workspace:^",
"next": "14.0.4",
"react": "^18",
"react-dom": "^18"
Expand Down
22 changes: 9 additions & 13 deletions examples/app-router/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,22 @@ You can check out the demo of [this page](https://github.com/mintlify/mdx/blob/m

## How to use

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

```tsx
import { getCompiledServerMdx } from '@mintlify/mdx';
import { MDXRemote } from '@mintlify/mdx';

export default async function Home() {
const { content, frontmatter } = await getCompiledServerMdx({
source: `---
title: Title
---

## Markdown H2
`,
});
const source: `---
title: Title
---

## Markdown H2
`;

return (
<article className="prose mx-auto py-8">
<h1>{String(frontmatter.title)}</h1>

{content}
<MDXRemote source={source} parseFrontmatter />
</article>
);
}
Expand Down
Loading