Docs: Document Fumadocs MDX v12

This commit is contained in:
Fuma Nama
2025-09-20 17:36:27 +08:00
parent 3e7e178cff
commit 22e0fec9ee
6 changed files with 108 additions and 7 deletions
+6 -1
View File
@@ -2,4 +2,9 @@
'fumadocs-mdx': major
---
[Next.js] Rename `_file` prop on page data to `info`, and replace `_file.absolutePath` with `info.fullPath`.
**[Next.js] Rename APIS**
On page data:
- `_file` -> `info`.
- `_file.absolutePath` -> `info.fullPath`.
+5
View File
@@ -0,0 +1,5 @@
---
'fumadocs-mdx': minor
---
**Support `getText()` & Postprocess API**
+1 -3
View File
@@ -2,6 +2,4 @@
'fumadocs-mdx': major
---
**Support `getText()` API & `postprocess.includeProcessedMarkdown` option.**
[Next.js] removed `content` on page data in favour of `getText()`.
**[Next.js] Removed `content` on page data in favour of `getText()`.**
+95
View File
@@ -0,0 +1,95 @@
---
title: Fumadocs MDX v12
description: Runtime improvements & LLM integrations.
date: 2025-09-20
author: Fuma Nama
---
## Overview
Fumadocs MDX v12 mainly aims to unify Fumadocs MDX on Vite and Next.js.
It contains renames to certain APIs (import paths are unaffected), migrations may be necessary.
## Breaking Changes
### Next.js
Removed `content` on page data in favour of `getText()`.
```ts tab="Before"
import { source } from '@/lib/source';
const page = source.getPage(['...']);
console.log(page.data.content);
```
```ts tab="After"
import { source } from '@/lib/source';
const page = source.getPage(['...']);
console.log(await page.data.getText('raw'));
```
API Renames on page data:
- `_file` -> `info`.
- `_file.absolutePath` -> `info.fullPath`.
```ts tab="Before"
import { source } from '@/lib/source';
const page = source.getPage(['...']);
console.log(page._file, page._file.absolutePath);
```
```ts tab="After"
import { source } from '@/lib/source';
const page = source.getPage(['...']);
console.log(page.info, page.info.fullPath);
```
## Improvements
### Vite
Added APIs for `info` to access raw file info.
```ts
import { source } from '@/lib/source';
const page = source.getPage(['...']);
console.log(page.info);
```
### `getText()`
You can use it to access:
- Raw Markdown content.
- Processed Markdown before being compiled into HAST (HTML).
This is useful for `llms.txt` generation when used with docs generations tools & remark plugins.
```ts
import { source } from '@/lib/source';
const page = source.getPage(['...']);
console.log(await page.data.getText('raw'));
console.log(await page.data.getText('processed'));
```
To access processed Markdown content, you need to enable `includeProcessedMarkdown` in collection config.
```ts title="source.config.ts"
import { defineDocs } from 'fumadocs-mdx/config';
export default defineDocs({
docs: {
postprocess: {
includeProcessedMarkdown: true,
},
},
});
```
@@ -13,7 +13,6 @@ Include the processed Markdown content into static information before being conv
```ts tab="docs"
import { defineDocs } from 'fumadocs-mdx/config';
import { myPlugin } from './remark-plugin';
export default defineDocs({
docs: {
@@ -27,7 +26,6 @@ export default defineDocs({
```ts tab="doc"
import { defineCollections } from 'fumadocs-mdx/config';
import { myPlugin } from './remark-plugin';
export default defineCollections({
type: 'doc',
@@ -45,7 +45,7 @@ function getHeadings({ data }: InferPageType<typeof source>): string[] {
function getFiles() {
const promises = source.getPages().map(
async (page): FileObject => ({
async (page): Promise<FileObject> => ({
path: page.absolutePath,
content: await page.data.getText('raw'),
url: page.url,