readMdx(options)

Read raw MDX file content. This is useful when you need the raw content without parsing or rendering.

Usage

import { readMdx } from "@ariadocs/react";

const raw = await readMdx({
  contentDir: "contents/docs",
  slug: "getting-started",
});

Parameters

options

PropertyTypeRequiredDescription
contentDirstringYesPath to the content directory
slugstringYesFile path without .mdx extension

Returns

Returns a string containing the raw MDX content including frontmatter.

Example

import { readMdx } from "@ariadocs/react";

export default async function RawContentPage() {
  const raw = await readMdx({
    contentDir: "contents/docs",
    slug: "getting-started",
  });

  return (
    <pre>
      <code>{raw}</code>
    </pre>
  );
}

Use Cases

  • Displaying raw MDX source code
  • Processing MDX content with custom logic
  • Building edit pages that show the original content
  • Debugging MDX files