// AI Directory Platform — 站点 Next.js 配置工厂 // 说明:站点 next.config.mjs 只需 `export { createSiteConfig as default } from "@aidir/core/next-config"` // MDX/intl/turbopack 等构建依赖由底座包解析,站点零构建依赖。 import fs from "node:fs"; import path from "node:path"; import rehypePrism from "@mapbox/rehype-prism"; import nextMDX from "@next/mdx"; import remarkGfm from "remark-gfm"; import createNextIntlPlugin from "next-intl/plugin"; /** * # 函数 createSiteConfig * 说明:底座统一的站点 Next 配置(next-intl + MDX + 图片域名 + standalone)。 * 参数:opts.requestPath 站点 i18n request 文件相对路径 * 返回值:完整 Next 配置 */ export function createSiteConfig({ requestPath = "./src/i18n/request.ts", } = {}) { const withNextIntl = createNextIntlPlugin(requestPath); /** @type {import('next').NextConfig} */ const nextConfig = { output: "standalone", transpilePackages: ["@aidir/core"], images: { // 工具 logo 指向各官网 favicon,域名不可枚举,放开 https 通配 remotePatterns: [{ protocol: "https", hostname: "**" }], }, pageExtensions: ["ts", "tsx", "mdx"], turbopack: { rules: { "*.mdx": { loaders: ["@mdx-js/loader"], as: "*.js", }, }, }, }; const withMDX = nextMDX({ extension: /\.mdx?$/, options: { remarkPlugins: [remarkGfm], rehypePlugins: [rehypePrism], }, }); return withNextIntl(withMDX(nextConfig)); } export default createSiteConfig;