更新配置,添加主题配置和编辑链接功能,支持多语言文档编辑

This commit is contained in:
2024-12-17 01:36:31 +08:00
parent 721904d4c3
commit 575993ebc4
6 changed files with 44 additions and 1 deletions

View File

@ -42,4 +42,40 @@ export function generateSidebarConfig(): VitePressSidebarOptions[] {
}
}
return ret
}
export const ThemeConfig = {
getEditLink: (editPageText: string): { pattern: (params: { filePath: string; }) => string; text: string; } => {
return {
pattern: ({filePath}: { filePath: string; }): string => {
if (!filePath) {
throw new Error("filePath is undefined");
}
const regex = /^(dev\/api|[^\/]+\/dev\/api)/;
if (regex.test(filePath)) {
filePath = filePath.replace(regex, '')
.replace('index.md', '__init__.py')
.replace('.md', '.py');
const fileName = filePath.split('/').pop();
const parentFolder = filePath.split('/').slice(-2, -1)[0];
if (fileName && parentFolder && fileName.split('.')[0] === parentFolder) {
filePath = filePath.split('/').slice(0, -1).join('/') + '/__init__.py';
}
return `https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/${filePath}`;
} else {
return `https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/docs/${filePath}`;
}
},
text: editPageText
};
},
getOutLine: (label: string): { label: string; level: [number, number]; } => {
return {
label: label,
level: [2, 6]
};
},
copyright: 'Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved'
}