靜態匯出
將您的頁面靜態匯出,並使用 Nginx、GitHub Pages 等進行部署。
開始使用
設定
next.config.mjs
import nextra from 'nextra'
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
output: 'export',
images: {
unoptimized: true // mandatory, otherwise won't export
}
// Optional: Change the output directory `out` -> `dist`
// distDir: "build"
}
const withNextra = nextra({
theme: 'nextra-theme-docs',
themeConfig: './theme.config.tsx'
})
export default withNextra(nextConfig)
建置
根據您的套件管理器執行 build
指令
npm run build
預設情況下,靜態匯出將儲存在專案根目錄的 out
目錄中。
有關靜態匯出的更多詳細文件,請參閱 Next.js 文件。