From 274fc82650e1ac159f78f1722b499f7944095b4b Mon Sep 17 00:00:00 2001 From: snowykami Date: Sat, 31 Aug 2024 17:31:29 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BF=AE=E6=94=B9dead=20link?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/.vitepress/config/utils.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/.vitepress/config/utils.ts b/docs/.vitepress/config/utils.ts index a2c6613..f379cbe 100644 --- a/docs/.vitepress/config/utils.ts +++ b/docs/.vitepress/config/utils.ts @@ -14,6 +14,10 @@ export const ThemeConfig = { filePath = filePath.replace(regex, '') .replace('index.md', '__init__.py') .replace('.md', '.py'); + // 若文件名(不含扩展)和上级文件夹相同,返回文件夹/__init__.py + if (filePath.split('/').pop().split('.')[0] === filePath.split('/').slice(-2, -1)[0]) { + filePath = filePath.split('/').slice(0, -1).join('/') + '/__init__.py'; + } return `https://github.com/snowykami/mbcp/tree/main/mbcp/${filePath}`; } else { return `https://github.com/snowykami/mbcp/tree/main/docs/${filePath}`;