靜態建置
使用 Fumadocs 輸出靜態網站。
設定
Fumadocs 預設採用伺服器優先的做法,因此需要有執行中的伺服器。 您可以透過設定 React Router 來輸出靜態建置。
靜態建置沒有伺服器,因此下列功能無法運作:
中介軟體也不會執行,因此頁面無法依 Accept 標頭提供 Markdown。
部署
使用 SPA 模式時,您可以將 build/client 目錄當作靜態網站部署。
別忘了預先算繪
在 SPA 模式下,所有伺服器端載入器都必須預先算繪。
詳細資訊請參閱 React Router 文件。
import type { Config } from '@react-router/dev/config';
import { glob } from 'node:fs/promises';
import { createGetUrl, getSlugs } from 'fumadocs-core/source';
const getUrl = createGetUrl('/docs');
export default {
// 停用 SSR
ssr: false,
async prerender({ getStaticPaths }) {
const paths: string[] = [...getStaticPaths()];
for await (const entry of glob('**/*.{md,mdx}', { cwd: 'content/docs' })) {
paths.push(getUrl(getSlugs(entry)));
}
return paths;
},
} satisfies Config;How is this guide?
最後更新於
