Skip to content

Commit

Permalink
docs: improve README for MDX setup
Browse files Browse the repository at this point in the history
  • Loading branch information
yoannfleurydev committed Jan 26, 2024
1 parent 97cae5f commit 16b151f
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions packages/typed-mdx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ other alternative to Astro Content Collection for Next.js.
## Installation

```bash
npm install typed-mdx zod @next/mdx @mdx-js/loader @mdx-js/react @types/mdx
yarn add typed-mdx zod @next/mdx @mdx-js/loader @mdx-js/react @types/mdx
pnpm add typed-mdx zod @next/mdx @mdx-js/loader @mdx-js/react @types/mdx
npm install typed-mdx zod @next/mdx @mdx-js/loader @mdx-js/react @types/mdx remark-frontmatter
yarn add typed-mdx zod @next/mdx @mdx-js/loader @mdx-js/react @types/mdx remark-frontmatter
pnpm add typed-mdx zod @next/mdx @mdx-js/loader @mdx-js/react @types/mdx remark-frontmatter
```

## Usage
Expand Down Expand Up @@ -63,3 +63,32 @@ export default async function Page() {
);
}
```

To show the MDX content, please note that it works with the `@next/mdx` package.
Setup the `next.config.mjs`:

```mjs
// Only support ESM so next.config.mjs
import remarkFrontmatter from "remark-frontmatter";
import createMDX from "@next/mdx";

/** @type {import('next').NextConfig} */
const nextConfig = {
transpilePackages: ["typed-mdx"],
// Configure `pageExtensions` to include MDX files
pageExtensions: ["js", "jsx", "mdx", "ts", "tsx"],
// Do not use the mdxRs yet as it does not support the remarkFrontmatter removal
// experimental: {
// mdxRs: true,
// },
};

const withMDX = createMDX({
options: {
// To remove frontmatter from rendering
remarkPlugins: [remarkFrontmatter],
},
});

export default withMDX(nextConfig);
```

0 comments on commit 16b151f

Please sign in to comment.