Beta

The Content & Documentation SDK for React

  • Author type-safe content
  • Generate type documentation
  • Preview source code
  • And so much more
Get Started
$npm create mdxts

docs

data.ts

data.ts
import { createSource } from 'mdxts'

export const allDocs = createSource('docs/*.mdx')

Sidebar.tsx

Sidebar.tsx
import Link from 'next/link'
import { Navigation } from 'mdxts/components'
import { allDocs } from './data'

export function Sidebar() {
  return (
    <Navigation
      source={allDocs}
      renderList={(props) => <ul>{props.children}</ul>}
      renderItem={(props) => (
        <li key={props.label}>
          {props.depth === 0 ? (
            <div>{props.label}</div>
          ) : (
            <Link href={props.pathname}>{props.label}</Link>
          )}
          {props.children}
        </li>
      )}
    />
  )
}

docs/[slug]/page.tsx

docs/[slug]/page.tsx
import { allDocs } from '../../data'

export default async function Page({ params }) {
  const { Content } = await allDocs.get(params.slug)
  return <Content />
}

Stay Updated

  • Find out about new features first
  • Stay updated on upcoming releases
  • Quality content, unsubscribe anytime