From d21a8b07d49aa0fbdaaa1d8ae5dcc4c7880ed45f Mon Sep 17 00:00:00 2001 From: xiaoyusu Date: Fri, 10 Apr 2026 00:25:03 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=E5=BC=95=E5=85=A5npm=E6=8B=BC?= =?UTF-8?q?=E9=9F=B3=E5=BA=93pinyin-pro=EF=BC=8C=E5=B0=86LeetCode=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E4=B8=8B=E7=9A=84=E6=96=87=E4=BB=B6=E5=90=8D=E7=9A=84?= =?UTF-8?q?=E4=B8=AD=E6=96=87=E5=AD=97=E7=AC=A6=E8=BD=AC=E6=8D=A2=E6=88=90?= =?UTF-8?q?=E6=8B=BC=E9=9F=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: karicms <148926657+karicms@users.noreply.github.com> --- lib/source.ts | 51 +++++++++++++++++++++++++++++++++++++++++++++++++- package.json | 1 + pnpm-lock.yaml | 8 ++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/lib/source.ts b/lib/source.ts index c5fb60a8..5981f4e2 100644 --- a/lib/source.ts +++ b/lib/source.ts @@ -1,7 +1,56 @@ import { docs } from "@/.source"; -import { loader } from "fumadocs-core/source"; +import { loader, getSlugs } from "fumadocs-core/source"; +import { pinyin } from "pinyin-pro"; + +// 拼音转换工具,仅针对中文部分转换,保留原本的标点和数字 +function convertSlugToPinyin(text: string) { + // 核心修复点:Fumadocs 内部生成的 slugs 可能是被 encode 处理过的(%E6%BC...),需要先解码再判断汉字 + const decodedText = decodeURIComponent(text); + + if (!/[\u4e00-\u9fa5]/.test(decodedText)) return text; + + return pinyin(decodedText, { + toneType: "none", + type: "array", + nonZh: "consecutive", + }) + .map((t) => t.toLowerCase().replace(/[^a-z0-9]/g, "")) // 进一步清理非字母数字字符 + .filter(Boolean) + .join("-"); +} + +console.log(">>> [Source.ts] 正在加载路由重映射插件..."); export const source = loader({ baseUrl: "/docs", source: docs.toFumadocsSource(), + transformers: [ + ({ storage }) => { + let count = 0; + for (const path of storage.getFiles()) { + const file = storage.read(path); + if ( + file && + file.format === "page" && + path.startsWith("CommunityShare/Leetcode/") + ) { + const defaultSlugs = getSlugs(path); + const newSlugs = defaultSlugs.map(convertSlugToPinyin); + + if (count < 3) { + console.log( + `>>> [Transformer] 映射样例: ${path} -> ${newSlugs.join("/")}`, + ); + } + + // 强制覆盖 Fumadocs-MDX 预生成的 slugs + file.slugs = newSlugs; + count++; + } + } + console.log( + `>>> [Transformer] 任务完成,共成功重映射 ${count} 条拼音路径。`, + ); + }, + ], }); diff --git a/package.json b/package.json index a7479a58..0b2b7a2a 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,7 @@ "next-auth": "5.0.0-beta.30", "next-intl": "^4.3.9", "pg": "^8.18.0", + "pinyin-pro": "^3.28.0", "react": "19.2.3", "react-dom": "19.2.3", "rehype-autolink-headings": "^7.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 75d8fc03..4c071c2f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -147,6 +147,9 @@ importers: pg: specifier: ^8.18.0 version: 8.18.0 + pinyin-pro: + specifier: ^3.28.0 + version: 3.28.0 react: specifier: 19.2.3 version: 19.2.3 @@ -5744,6 +5747,9 @@ packages: engines: {node: '>=0.10'} hasBin: true + pinyin-pro@3.28.0: + resolution: {integrity: sha512-mMRty6RisoyYNphJrTo3pnvp3w8OMZBrXm9YSWkxhAfxKj1KZk2y8T2PDIZlDDRsvZ0No+Hz6FI4sZpA6Ey25g==} + pkg-types@2.3.0: resolution: {integrity: sha512-SIqCzDRg0s9npO5XQ3tNZioRY1uK06lA41ynBC1YmFTmnY6FjUjVt6s4LoADmwoig1qqD0oK8h1p/8mlMx8Oig==} @@ -13951,6 +13957,8 @@ snapshots: pidtree@0.6.0: {} + pinyin-pro@3.28.0: {} + pkg-types@2.3.0: dependencies: confbox: 0.2.2 From b3714bf1c2cb27ee0a5273136730c50eb56838d1 Mon Sep 17 00:00:00 2001 From: xiaoyusu Date: Fri, 10 Apr 2026 00:29:54 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E5=B5=8C?= =?UTF-8?q?=E5=A5=97=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../prompt-repetition-improves-non-reasoning-llms.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/docs/CommunityShare/Amazing-AI-Tools/prompt-repetition-improves-non-reasoning-llms.md b/app/docs/CommunityShare/Amazing-AI-Tools/prompt-repetition-improves-non-reasoning-llms.md index f32ab043..4a072af6 100644 --- a/app/docs/CommunityShare/Amazing-AI-Tools/prompt-repetition-improves-non-reasoning-llms.md +++ b/app/docs/CommunityShare/Amazing-AI-Tools/prompt-repetition-improves-non-reasoning-llms.md @@ -9,7 +9,7 @@ tags: docId: l6eepr5ctjgrhdgupy3twr1t --- -# + When not using reasoning, repeating the input prompt improves performance for popular models (Gemini, GPT, Claude, and Deepseek) without increasing the number of generated tokens or latency. From 0aac7a9a80d4e3e3044d7e0f54e61ae213a0a36a Mon Sep 17 00:00:00 2001 From: xiaoyusu Date: Fri, 10 Apr 2026 00:45:11 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix=EF=BC=9A=E5=8E=BB=E9=99=A4=E6=89=93?= =?UTF-8?q?=E5=8D=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/source.ts | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/lib/source.ts b/lib/source.ts index 5981f4e2..ac9a4073 100644 --- a/lib/source.ts +++ b/lib/source.ts @@ -19,8 +19,6 @@ function convertSlugToPinyin(text: string) { .join("-"); } -console.log(">>> [Source.ts] 正在加载路由重映射插件..."); - export const source = loader({ baseUrl: "/docs", source: docs.toFumadocsSource(), @@ -37,20 +35,11 @@ export const source = loader({ const defaultSlugs = getSlugs(path); const newSlugs = defaultSlugs.map(convertSlugToPinyin); - if (count < 3) { - console.log( - `>>> [Transformer] 映射样例: ${path} -> ${newSlugs.join("/")}`, - ); - } - // 强制覆盖 Fumadocs-MDX 预生成的 slugs file.slugs = newSlugs; count++; } } - console.log( - `>>> [Transformer] 任务完成,共成功重映射 ${count} 条拼音路径。`, - ); }, ], }); From 766255669bac5cb3df23359290368d3e1acf7c28 Mon Sep 17 00:00:00 2001 From: xiaoyusu Date: Fri, 10 Apr 2026 00:51:19 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20=E5=8E=BB=E9=99=A4=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E7=94=A8=E4=B8=8A=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/source.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/source.ts b/lib/source.ts index ac9a4073..a36644f2 100644 --- a/lib/source.ts +++ b/lib/source.ts @@ -24,7 +24,6 @@ export const source = loader({ source: docs.toFumadocsSource(), transformers: [ ({ storage }) => { - let count = 0; for (const path of storage.getFiles()) { const file = storage.read(path); if ( @@ -37,7 +36,6 @@ export const source = loader({ // 强制覆盖 Fumadocs-MDX 预生成的 slugs file.slugs = newSlugs; - count++; } } },