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. diff --git a/lib/source.ts b/lib/source.ts index c5fb60a8..a36644f2 100644 --- a/lib/source.ts +++ b/lib/source.ts @@ -1,7 +1,43 @@ 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("-"); +} export const source = loader({ baseUrl: "/docs", source: docs.toFumadocsSource(), + transformers: [ + ({ storage }) => { + 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); + + // 强制覆盖 Fumadocs-MDX 预生成的 slugs + file.slugs = newSlugs; + } + } + }, + ], }); 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