mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-26 23:49:51 +00:00
Docs: Document Fumadocs MDX v12
This commit is contained in:
@@ -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`.
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'fumadocs-mdx': minor
|
||||
---
|
||||
|
||||
**Support `getText()` & Postprocess API**
|
||||
@@ -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()`.**
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user