Ariadocs

Render MDX in a Server Component.

parseMdx is what docs.parse calls. Use it directly when you don't need a docs object, or when the MDX is a string.

import { parseMdx } from "@ariadocs/mdx";

export default async function Page() {
  const { MDX, frontmatter } = await parseMdx({ contentDir: "content/docs", slug: "intro" });

  return (
    <article>
      <h1>{frontmatter.title}</h1>
      {MDX}
    </article>
  );
}

It returns:

FieldContents
MDXThe rendered page
frontmatterThe parsed frontmatter
tocHeadings as { value, href, depth }
contentThe MDX without frontmatter
sourceThe original file contents

If you already have the MDX body, render it with MdxServer:

import { MdxServer } from "@ariadocs/mdx/server";

<MdxServer source={body} rehypePlugins={[rehypeSlug]} components={{ Callout }} />;