diff --git a/README.en.md b/README.en.md index 8f6c6fb..52cc6cf 100644 --- a/README.en.md +++ b/README.en.md @@ -3,7 +3,7 @@
diff --git a/README.md b/README.md index 3806d70..f214e01 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ diff --git a/app/components/DocShareButton.tsx b/app/components/DocShareButton.tsx index a92d64d..d293457 100644 --- a/app/components/DocShareButton.tsx +++ b/app/components/DocShareButton.tsx @@ -20,7 +20,12 @@ export function DocShareButton() { }, []); const handleCopy = async () => { - const url = window.location.href; + // 用户点"复制链接"必然是要发到外面(DC/微信/X) + // 给链接打上 UTM,回流时能在 GA Source 维度看到 doc_share,区别于 (direct) + const target = new URL(window.location.href); + target.searchParams.set("utm_source", "doc_share"); + target.searchParams.set("utm_medium", "user_share"); + const url = target.toString(); try { await navigator.clipboard.writeText(url); setCopied(true); diff --git a/next.config.mjs b/next.config.mjs index 79863fe..e2e25af 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -1,8 +1,18 @@ // next.config.mjs +import path from "node:path"; +import { fileURLToPath } from "node:url"; import { createMDX } from "fumadocs-mdx/next"; import createNextIntlPlugin from "next-intl/plugin"; import { withSentryConfig } from "@sentry/nextjs"; +// Next.js 16 detects multi-lockfile environments by searching upward for +// pnpm-lock.yaml / package-lock.json / yarn.lock. 当父目录意外有 lockfile +// 时(如开发服务器上 /home/ubuntu/package-lock.json),Next 会把 workspace +// root 推到上层,turbopack 跟着到错的目录解析 node_modules, +// 触发 "Can't resolve 'tailwindcss'" 之类报错。 +// 显式锁定到 frontend 自己目录,turbopack + outputFileTracing 双保险。 +const projectRoot = path.dirname(fileURLToPath(import.meta.url)); + /** * IMPORTANT: remarkImage 配置已移至 source.config.ts 统一管理 * @@ -22,6 +32,12 @@ const withNextIntl = createNextIntlPlugin("./i18n/request.ts"); /** @type {import('next').NextConfig} */ const config = { reactStrictMode: true, + // 强制锁定 turbopack 和 SSR file tracing 的根目录到 frontend/ 自己, + // 避免上层意外 lockfile 把 root 推错(详见文件顶部注释)。 + turbopack: { + root: projectRoot, + }, + outputFileTracingRoot: projectRoot, /** * docs 目录整理产生的 URL 变化 → 301 重定向。 *