Files
ai-directory-platform/packages/core/next-config.mjs
T
bigcode 05440ffb5b feat: 服务器迁移后的全量演进(依赖升级/安全审计/设计统一/截图/SEO 底座化)
在原仓库历史之上同步本服务器上的全部演进:

- 迁移至新服务器并重建 PG 数据库 + ddnc 开发域名绑定
- 全部依赖升级至最新(Next 16.3.5 / React 19.3 / better-auth 1.7.5 / Drizzle 0.45 / TS 7),
  overrides 消除已知 CVE,安全审计 19 项发现全部修复闭环
- 设计统一:各站宽度 token(--container + site-container)、classic hero 重设计、
  头部换行修复、页面过渡与 View Transitions
- 截图功能:api.adx9.com 截图服务接入(ow=800 本地化 webp、cf=1、去重/限流/占位图)
- SEO 底座化:canonical/hreflang/sitemap/JSON-LD/robots 全部收进 core,新站自动继承
- 加载体验:五站五形态路由骨架(data-theme 切换、shimmer 微光、延迟淡入)+
  过滤 useTransition 交叉淡入淡出(card-enter 错峰入场)
- 构建:experimental.cpus 限流防 PG 连接打满;清理死组件链
2026-09-15 18:19:53 +08:00

74 lines
2.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 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 nextMDX from "@next/mdx";
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",
poweredByHeader: false,
transpilePackages: ["@aidir/core"],
// 静态生成 worker 上限:每个 worker 各持 DB 连接池,并发过高会把
// PostgreSQL 的 max_connections 打满("sorry, too many clients already")
experimental: {
cpus: 8,
},
// 安全响应头:防点击劫持 / MIME 嗅探 / 引用泄漏,权限收敛
async headers() {
return [
{
source: "/(.*)",
headers: [
{ key: "X-Frame-Options", value: "SAMEORIGIN" },
{ key: "X-Content-Type-Options", value: "nosniff" },
{
key: "Referrer-Policy",
value: "strict-origin-when-cross-origin",
},
{
key: "Permissions-Policy",
value:
"camera=(), microphone=(), geolocation=(), interest-cohort=()",
},
],
},
];
},
images: {
// 工具 logo 指向各官网 favicon,域名不可枚举,放开 https 通配
remotePatterns: [{ protocol: "https", hostname: "**" }],
},
pageExtensions: ["ts", "tsx", "mdx"],
};
const withMDX = nextMDX({
extension: /\.mdx?$/,
options: {
// Turbopack 要求 loader options 可序列化:插件用模块路径字符串,
// 由 @next/mdx 16 的 loader 在构建时动态 import(@mdx-js/loader 支持)
remarkPlugins: ["remark-gfm"],
rehypePlugins: ["@mapbox/rehype-prism"],
},
});
return withNextIntl(withMDX(nextConfig));
}
export default createSiteConfig;