Skip to content

Commit ea25a68

Browse files
author
lipeng hao
committed
feat: add VitePress documentation site with i18n support
- Add VitePress configuration with Chinese/English switching - Create documentation structure under docs/ directory - Add GitHub Actions workflow for automatic deployment to GitHub Pages - Include 17 lessons in Chinese, 13 lessons in English - Configure local search and dark mode support
1 parent 88c5509 commit ea25a68

36 files changed

Lines changed: 11038 additions & 0 deletions

.github/workflows/deploy.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# VitePress 文档部署工作流
2+
# 自动将文档部署到 GitHub Pages
3+
4+
name: Deploy VitePress to GitHub Pages
5+
6+
on:
7+
# 推送到 master 分支时触发
8+
push:
9+
branches: [master]
10+
# 允许手动触发
11+
workflow_dispatch:
12+
13+
# 设置 GITHUB_TOKEN 权限
14+
permissions:
15+
contents: read
16+
pages: write
17+
id-token: write
18+
19+
# 只允许同时进行一次部署
20+
concurrency:
21+
group: pages
22+
cancel-in-progress: false
23+
24+
jobs:
25+
# 构建任务
26+
build:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
34+
- name: Setup Node
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version: 20
38+
cache: npm
39+
40+
- name: Setup Pages
41+
uses: actions/configure-pages@v4
42+
43+
- name: Install dependencies
44+
run: npm ci
45+
46+
- name: Build with VitePress
47+
run: npm run docs:build
48+
49+
- name: Upload artifact
50+
uses: actions/upload-pages-artifact@v3
51+
with:
52+
path: docs/.vitepress/dist
53+
54+
# 部署任务
55+
deploy:
56+
environment:
57+
name: github-pages
58+
url: ${{ steps.deployment.outputs.page_url }}
59+
needs: build
60+
runs-on: ubuntu-latest
61+
name: Deploy
62+
steps:
63+
- name: Deploy to GitHub Pages
64+
id: deployment
65+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,9 @@ src/libbpfgo-helloworld/helloworld
3636
*~
3737
.vscode/
3838
.idea/
39+
40+
# Node.js / VitePress
41+
node_modules/
42+
docs/.vitepress/dist/
43+
docs/.vitepress/cache/
44+
package-lock.json

docs/.vitepress/config.mts

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
import { defineConfig } from 'vitepress'
2+
3+
export default defineConfig({
4+
title: 'eBPF Tutorial',
5+
description: 'Learn eBPF programming from scratch',
6+
base: '/ebpf-tutorial/',
7+
8+
head: [
9+
['link', { rel: 'icon', href: '/ebpf-tutorial/favicon.ico' }]
10+
],
11+
12+
// 多语言配置
13+
locales: {
14+
root: {
15+
label: 'English',
16+
lang: 'en',
17+
themeConfig: {
18+
nav: [
19+
{ text: 'Home', link: '/' },
20+
{ text: 'Guide', link: '/guide/lesson-1-helloworld' }
21+
],
22+
sidebar: {
23+
'/guide/': [
24+
{
25+
text: 'Getting Started',
26+
items: [
27+
{ text: 'Lesson 1: Hello World', link: '/guide/lesson-1-helloworld' }
28+
]
29+
},
30+
{
31+
text: 'Hook Mechanisms',
32+
items: [
33+
{ text: 'Lesson 2: Kprobe', link: '/guide/lesson-2-kprobe' },
34+
{ text: 'Lesson 3: Uprobe', link: '/guide/lesson-3-uprobe' },
35+
{ text: 'Lesson 8: Tracepoint', link: '/guide/lesson-8-tracepoint' },
36+
{ text: 'Lesson 9: Raw Tracepoint', link: '/guide/lesson-9-raw-tracepoint' }
37+
]
38+
},
39+
{
40+
text: 'Data Structures',
41+
items: [
42+
{ text: 'Lesson 4: User Map', link: '/guide/lesson-4-user-map' },
43+
{ text: 'Lesson 5: Kernel User Map', link: '/guide/lesson-5-kernel-user-map' },
44+
{ text: 'Lesson 7: Ring/Perf Buffer', link: '/guide/lesson-7-ringbuffer-perfbuffer' }
45+
]
46+
},
47+
{
48+
text: 'Network Programming',
49+
items: [
50+
{ text: 'Lesson 11: TC Ingress', link: '/guide/lesson-11-tc-ingress' },
51+
{ text: 'Lesson 12: TC Egress', link: '/guide/lesson-12-tc-egress' }
52+
]
53+
},
54+
{
55+
text: 'Advanced Topics',
56+
items: [
57+
{ text: 'Lesson 6: Go Development', link: '/guide/lesson-6-golang-develop' },
58+
{ text: 'Lesson 10: BTF', link: '/guide/lesson-10-btf' },
59+
{ text: 'Lesson 13: SSL Sniff', link: '/guide/lesson-13-ssl-sniff' }
60+
]
61+
}
62+
]
63+
}
64+
}
65+
},
66+
zh: {
67+
label: '简体中文',
68+
lang: 'zh-CN',
69+
link: '/zh/',
70+
themeConfig: {
71+
nav: [
72+
{ text: '首页', link: '/zh/' },
73+
{ text: '教程', link: '/zh/guide/lesson-1-helloworld' }
74+
],
75+
sidebar: {
76+
'/zh/guide/': [
77+
{
78+
text: '快速开始',
79+
items: [
80+
{ text: 'Lesson 1: Hello World', link: '/zh/guide/lesson-1-helloworld' }
81+
]
82+
},
83+
{
84+
text: 'Hook 机制',
85+
items: [
86+
{ text: 'Lesson 2: Kprobe', link: '/zh/guide/lesson-2-kprobe' },
87+
{ text: 'Lesson 3: Uprobe', link: '/zh/guide/lesson-3-uprobe' },
88+
{ text: 'Lesson 8: Tracepoint', link: '/zh/guide/lesson-8-tracepoint' },
89+
{ text: 'Lesson 9: Raw Tracepoint', link: '/zh/guide/lesson-9-raw-tracepoint' }
90+
]
91+
},
92+
{
93+
text: '数据结构',
94+
items: [
95+
{ text: 'Lesson 4: 用户态 Map', link: '/zh/guide/lesson-4-user-map' },
96+
{ text: 'Lesson 5: 内核态 Map', link: '/zh/guide/lesson-5-kernel-user-map' },
97+
{ text: 'Lesson 7: Ring/Perf Buffer', link: '/zh/guide/lesson-7-ringbuffer-perfbuffer' }
98+
]
99+
},
100+
{
101+
text: '网络编程',
102+
items: [
103+
{ text: 'Lesson 11: TC Ingress', link: '/zh/guide/lesson-11-tc-ingress' },
104+
{ text: 'Lesson 12: TC Egress', link: '/zh/guide/lesson-12-tc-egress' },
105+
{ text: 'Lesson 17: XDP 过滤', link: '/zh/guide/lesson-17-xdp-filter' }
106+
]
107+
},
108+
{
109+
text: '高级主题',
110+
items: [
111+
{ text: 'Lesson 6: Go 语言开发', link: '/zh/guide/lesson-6-golang-develop' },
112+
{ text: 'Lesson 10: BTF', link: '/zh/guide/lesson-10-btf' },
113+
{ text: 'Lesson 13: SSL Sniff', link: '/zh/guide/lesson-13-ssl-sniff' }
114+
]
115+
},
116+
{
117+
text: '实战项目',
118+
items: [
119+
{ text: 'Lesson 14: HTTPS 流量监控', link: '/zh/guide/lesson-14-ssl-traffic-monitor' },
120+
{ text: 'Lesson 15: 进程命令监控', link: '/zh/guide/lesson-15-exec-command-monitor' },
121+
{ text: 'Lesson 16: Bash 命令监控', link: '/zh/guide/lesson-16-bash-readline-monitor' }
122+
]
123+
}
124+
]
125+
},
126+
outlineTitle: '本页目录',
127+
lastUpdatedText: '最后更新',
128+
docFooter: {
129+
prev: '上一篇',
130+
next: '下一篇'
131+
}
132+
}
133+
}
134+
},
135+
136+
themeConfig: {
137+
// 搜索
138+
search: {
139+
provider: 'local',
140+
options: {
141+
locales: {
142+
zh: {
143+
translations: {
144+
button: {
145+
buttonText: '搜索文档',
146+
buttonAriaLabel: '搜索文档'
147+
},
148+
modal: {
149+
noResultsText: '无法找到相关结果',
150+
resetButtonTitle: '清除查询条件',
151+
footer: {
152+
selectText: '选择',
153+
navigateText: '切换'
154+
}
155+
}
156+
}
157+
}
158+
}
159+
}
160+
},
161+
162+
// 社交链接
163+
socialLinks: [
164+
{ icon: 'github', link: 'https://github.com/haolipeng/ebpf-tutorial' }
165+
],
166+
167+
// 页脚
168+
footer: {
169+
message: 'Released under the MIT License.',
170+
copyright: 'Copyright © 2024-present haolipeng'
171+
},
172+
173+
// 编辑链接
174+
editLink: {
175+
pattern: 'https://github.com/haolipeng/ebpf-tutorial/edit/master/docs/:path',
176+
text: 'Edit this page on GitHub'
177+
}
178+
}
179+
})

0 commit comments

Comments
 (0)