Skip to content

Commit d047255

Browse files
committed
feat: ✨ 添加团队页面
1 parent 440b602 commit d047255

3 files changed

Lines changed: 83 additions & 39 deletions

File tree

docs/.vitepress/config.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default defineConfig({
1515
sidebar: generateSidebar(),
1616

1717
socialLinks: [
18-
{ icon: 'github', link: 'https://github.com/vuejs/vitepress' }
18+
{ icon: 'github', link: 'https://github.com/EzStars' }
1919
]
2020
},
2121
base: '/EzMonitor/', // 部署到github时需要设置

docs/.vitepress/utils/gennerateSidebar.ts

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ interface SidebarItem {
99
collapsed?: boolean;
1010
}
1111

12+
interface SidebarConfig {
13+
[key: string]: SidebarItem[];
14+
}
15+
1216
const EXCLUDE_FILES = [
1317
'.vitepress',
1418
'node_modules',
@@ -17,49 +21,45 @@ const EXCLUDE_FILES = [
1721
'assets',
1822
];
1923

20-
export function generateSidebar(): SidebarItem[] {
24+
export function generateSidebar(): SidebarConfig {
2125
const docsPath = path.resolve(__dirname, '../../');
22-
const items: SidebarItem[] = [];
26+
const sidebarConfig: SidebarConfig = {};
27+
28+
// 获取所有一级目录
29+
const directories = fs.readdirSync(docsPath).filter(file => {
30+
const filePath = path.join(docsPath, file);
31+
return fs.statSync(filePath).isDirectory() && !EXCLUDE_FILES.includes(file);
32+
});
33+
34+
// 为每个一级目录生成侧边栏配置
35+
directories.forEach(dir => {
36+
const dirPath = path.join(docsPath, dir);
37+
sidebarConfig[`/${dir}/`] = walkDir(dirPath);
38+
});
2339

24-
// 读取docs目录
40+
// 根目录的侧边栏配置
41+
sidebarConfig['/'] = generateRootSidebar(docsPath);
42+
43+
return sidebarConfig;
44+
}
45+
46+
function generateRootSidebar(docsPath: string): SidebarItem[] {
47+
const items: SidebarItem[] = [];
2548
const files = fs
2649
.readdirSync(docsPath)
27-
.filter(file => !EXCLUDE_FILES.includes(file))
28-
.sort((a, b) => {
29-
// 目录优先,同类型按字母排序
30-
const aStats = fs.statSync(path.join(docsPath, a));
31-
const bStats = fs.statSync(path.join(docsPath, b));
32-
if (aStats.isDirectory() && !bStats.isDirectory()) return -1;
33-
if (!aStats.isDirectory() && bStats.isDirectory()) return 1;
34-
return a.localeCompare(b);
35-
});
50+
.filter(
51+
file =>
52+
!EXCLUDE_FILES.includes(file) &&
53+
file.endsWith('.md') &&
54+
file !== 'README.md',
55+
)
56+
.sort();
3657

3758
files.forEach(file => {
38-
const filePath = path.join(docsPath, file);
39-
const stat = fs.statSync(filePath);
40-
41-
// 忽略以.开头的文件和README.md
42-
if (file.startsWith('.') || file === 'README.md') {
43-
return;
44-
}
45-
46-
if (stat.isDirectory()) {
47-
const children = walkDir(filePath);
48-
// 只有当目录非空时才添加
49-
if (children.length > 0) {
50-
items.push({
51-
text: formatText(file),
52-
items: children,
53-
collapsible: true,
54-
collapsed: false,
55-
});
56-
}
57-
} else if (file.endsWith('.md')) {
58-
items.push({
59-
text: formatText(file.replace('.md', '')),
60-
link: `/${file.replace('.md', '')}`,
61-
});
62-
}
59+
items.push({
60+
text: formatText(file.replace('.md', '')),
61+
link: `/${file.replace('.md', '')}`,
62+
});
6363
});
6464

6565
return items;
@@ -108,7 +108,6 @@ function walkDir(dir: string): SidebarItem[] {
108108
}
109109

110110
function formatText(text: string): string {
111-
// 将文件名转换为更友好的显示文本
112111
return text
113112
.replace(/-/g, ' ')
114113
.split(' ')

docs/使用文档/团队页.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
layout: page
3+
---
4+
<script setup>
5+
import {
6+
VPTeamPage,
7+
VPTeamPageTitle,
8+
VPTeamMembers
9+
} from 'vitepress/theme'
10+
11+
const members = [
12+
{
13+
avatar: 'https://avatars.githubusercontent.com/u/146628596?v=4',
14+
name: 'Ni0duann',
15+
title: 'Creator',
16+
links: [
17+
{ icon: 'github', link: 'https://github.com/Ni0duann' },
18+
// { icon: 'twitter', link: 'https://twitter.com/youyuxi' }
19+
]
20+
},
21+
{
22+
avatar: 'https://avatars.githubusercontent.com/u/109895777?v=4',
23+
name: 'Zero1017',
24+
title: '职位头衔',
25+
links: [
26+
{ icon: 'github', link: 'https://github.com/Eomnational' }
27+
]
28+
}
29+
// 可以继续添加更多成员
30+
]
31+
</script>
32+
33+
<VPTeamPage>
34+
<VPTeamPageTitle>
35+
<template #title>
36+
我们的团队
37+
</template>
38+
<template #lead>
39+
EzMonitor 由一群充满热情的开发者构建,以下是我们的核心团队成员。
40+
</template>
41+
</VPTeamPageTitle>
42+
<VPTeamMembers
43+
:members="members"
44+
/>
45+
</VPTeamPage>

0 commit comments

Comments
 (0)