Documentation
Learn how to write documentation using Content Collections and Fumadocs.
The starter kit uses Content Collections for managing documentation content. All documentation pages are written using .mdx files and rendered with Fumadocs.
Why choose Content Collections + Fumadocs? Content Collections provides type-safe content management, while Fumadocs offers beautiful documentation UI components. Together, they create a powerful documentation system that's easy to maintain and extend.
Documentation Structure
Documentation is organized in the content/docs directory. Each starter kit has its own subdirectory:
content/docs/pro-nextjs-drizzle/- Documentation for the Drizzle starter kitcontent/docs/pro-nextjs-prisma/- Documentation for the Prisma starter kit
Add a new documentation page
To create a new documentation page, follow these steps:
-
Create a new file Navigate to the appropriate documentation directory (e.g.,
content/docs/pro-nextjs-drizzle/) and create a new.mdxfile. The file name and path will determine the URL structure. For example:- File path:
content/docs/pro-nextjs-drizzle/cms/blog.mdx - URL:
https://your-app.com/docs/starter-kits/pro-nextjs-drizzle/cms/blog
- File path:
-
Add metadata At the top of the
.mdxfile, include a frontmatter block:
---
title: Example Page
section: General
category: CMS
description: An example documentation page.
---Frontmatter Fields
The documentation schema supports the following fields:
title(required) - The title of the pagedescription(required) - A short descriptionsection(optional) - Section grouping (e.g., "General", "Codebase")category(optional) - Category for organizationtoc(optional) - Boolean to enable/disable table of contents (default: true)featured(optional) - Boolean to mark pages as featured
Navigation Structure
Documentation navigation is configured in config/docs.tsx. To add a new page to the navigation:
{
title: 'CMS',
href: '/docs/starter-kits/pro-nextjs-drizzle/cms',
items: [
{
title: 'Blog',
href: '/docs/starter-kits/pro-nextjs-drizzle/cms/blog',
items: []
},
{
title: 'Documentation',
href: '/docs/starter-kits/pro-nextjs-drizzle/cms/documentation',
items: []
}
],
collapsible: true
}Using MDX Components
Fumadocs and the starter kit provide many custom components:
Callouts
<Callout className="mt-4">This is a regular callout.</Callout>
<Callout
type="warning"
className="mt-4"
>
This is a warning callout.
</Callout>
<Callout
type="error"
className="mt-4"
>
This is an error callout.
</Callout>Code Blocks
Code blocks support syntax highlighting, line numbers, and file names:
export function example() {
return 'Hello, World!';
}Linked Cards
Create navigation cards:
<LinkedCardGrid>
<LinkedCard
href="/docs/starter-kits/pro-nextjs-drizzle/cms/blog"
header="Blog"
description="Learn how to write blog posts."
/>
</LinkedCardGrid>Steps
Guide users through processes:
<Steps>
<Step>First step</Step>
<Step>Second step</Step>
<Step>Third step</Step>
</Steps>Code Imports
You can import code from your codebase directly into documentation:
import { Example } from './example.tsx';
<Example />Building Documentation
Content Collections are automatically built during the Next.js build process. During development, they are rebuilt when files change.
Querying Documentation
You can query documentation pages in your application:
import { allDocuments } from 'content-collections/generated';
export default function DocsPage() {
const docs = allDocuments('ProNextjsDrizzle');
return (
<div>
{docs.map((doc) => (
<article key={doc.slug}>
<h2>{doc.title}</h2>
<p>{doc.description}</p>
</article>
))}
</div>
);
}Configuration
Documentation collections are configured in content-collections.ts:
const ProNextjsDrizzle = createCollection(
'ProNextjsDrizzle',
'docs/pro-nextjs-drizzle/**/*.mdx'
);
export default defineConfig({
collections: [
// ... other collections
ProNextjsDrizzle
]
});Fumadocs Features
Fumadocs provides additional features:
- Automatic table of contents - Generated from headings
- Search - Full-text search across documentation
- Dark mode - Automatic theme switching
- Responsive design - Mobile-friendly layouts
- Type safety - TypeScript support for content
Best Practices
- Use clear titles - Make titles descriptive and searchable
- Add descriptions - Help with SEO and search results
- Organize with sections - Group related pages together
- Use code examples - Include practical examples
- Keep it updated - Update docs when code changes
- Test locally - Always preview documentation before publishing