mbcp/docs/.vitepress/config/utils.ts

34 lines
1.2 KiB
TypeScript
Raw Normal View History

2024-08-31 07:40:03 +08:00
// 本模块储存一些工具函数和引用
2024-08-31 06:06:32 +08:00
/**
* GetEditLink Options
* @param text Edit link text
*/
export const ThemeConfig = {
getEditLink: (editPageText: string): { pattern: (params: { filePath: string; }) => string; text: string; } => {
return {
pattern: ({filePath}: { filePath: string; }): string => {
const regex = /^[^\/]+\/api/;
if (regex.test(filePath)) {
// remove {lang}/api prefix
filePath = filePath.replace(regex, '')
.replace('index.md', '__init__.py')
.replace('.md', '.py');
return `https://github.com/snowykami/mbcp/tree/main/mbcp/${filePath}`;
} else {
return `https://github.com/snowykami/mbcp/tree/main/docs/${filePath}`;
}
},
text: editPageText
};
2024-08-31 07:40:03 +08:00
},
getOutLine: (label: string): { label: string; level: [number, number]; } => {
return {
label: label,
level: [2, 6]
};
},
copyright: 'Copyright (C) 2020-2024 SnowyKami. All Rights Reserved'
2024-08-31 06:06:32 +08:00
}