Skip to content

Commit 70a5728

Browse files
fix(redirect+docs): 补 language/papers 精确 index 301 + 删 syncedFromPosts 死代码
Copilot CR(#351): - next.config.mjs:language / papers 各补一条无 :path* 的精确 index 规则, 防止空路径命中 :path* wildcard 产生尾斜杠,避免 301→308 双跳。 - page.tsx:删 syncedFromPosts eyebrow 渲染块(删+301 路线已无 doc 携带该字段)。 - doc.ts:删 PageData 的 syncedFromPosts / syncedAuthor / syncedPostsUrl 字段(死代码)。 Co-authored-by: copilot-pull-request-reviewer[bot] <198982749+copilot-pull-request-reviewer[bot]@users.noreply.github.com>
1 parent c406f09 commit 70a5728

3 files changed

Lines changed: 12 additions & 18 deletions

File tree

app/[locale]/docs/[...slug]/page.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,6 @@ export default async function DocPage({ params }: Param) {
126126
/>
127127
<DocsPage toc={page.data.toc}>
128128
<DocsBody>
129-
{data.syncedFromPosts && data.syncedPostsUrl && (
130-
<p className="font-mono text-[10px] uppercase tracking-widest text-neutral-500 mb-4">
131-
此文同步自作者主页 →{" "}
132-
<a
133-
href={data.syncedPostsUrl}
134-
className="underline hover:text-neutral-700 dark:hover:text-neutral-300 transition-colors"
135-
>
136-
{data.syncedAuthor ? `${data.syncedAuthor} 的文章` : "原文"}
137-
</a>
138-
</p>
139-
)}
140129
<div className="mb-6 flex flex-col gap-3 border-b border-border pb-6 md:mb-8 md:flex-row md:items-start md:justify-between">
141130
<h1 className="text-3xl font-extrabold tracking-tight md:text-4xl">
142131
{page.data.title}

app/types/doc.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ export interface PageData {
3939
lang?: string;
4040
[key: string]: unknown;
4141
};
42-
// docs 文章同步自作者 posts 主页时在 frontmatter 设置,
43-
// 渲染层据此在文章顶部加「此文同步自作者主页 →」导航提示。
44-
syncedFromPosts?: boolean;
45-
syncedAuthor?: string;
46-
syncedPostsUrl?: string;
4742
// 故意不挂顶层 [key: string]: unknown 索引签名 —— Fumadocs 的 page.data 由
4843
// zod DocOut 推出,没有 index signature;如果在 PageData 上挂一个,as PageData
4944
// 会触发 TS2352 "neither type sufficiently overlaps"。所有需要的字段都已

next.config.mjs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,23 @@ const config = {
227227
destination: "/zh/docs/learn/cs/dev-tips/:path*",
228228
statusCode: 301,
229229
},
230-
// language(语言考试)→ career/language
230+
// language(语言考试)→ career/language;精确 index + wildcard 各一条,防空路径双跳
231+
{
232+
source: "/docs/community/language",
233+
destination: "/zh/docs/career/language",
234+
statusCode: 301,
235+
},
231236
{
232237
source: "/docs/community/language/:path*",
233238
destination: "/zh/docs/career/language/:path*",
234239
statusCode: 301,
235240
},
236-
// papers(AI 论文读书笔记)→ learn/ai/papers
241+
// papers(AI 论文读书笔记)→ learn/ai/papers;同上
242+
{
243+
source: "/docs/community/papers",
244+
destination: "/zh/docs/learn/ai/papers",
245+
statusCode: 301,
246+
},
237247
{
238248
source: "/docs/community/papers/:path*",
239249
destination: "/zh/docs/learn/ai/papers/:path*",

0 commit comments

Comments
 (0)