Skip to content

Commit d03bd70

Browse files
update book.toml and ci
1 parent 29e637c commit d03bd70

File tree

2 files changed

+16
-124
lines changed

2 files changed

+16
-124
lines changed

.github/workflows/deploy.yml

Lines changed: 14 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,27 @@
1-
name: Deploy mdBook
1+
name: Deploy mdBook to GitHub Pages
22

33
on:
44
push:
5-
branches: [ "main" ]
6-
workflow_dispatch:
5+
branches:
6+
- main
77

88
jobs:
9-
deploy:
9+
build:
1010
runs-on: ubuntu-latest
11-
steps:
12-
- uses: actions/checkout@v4
13-
14-
# 1. 设置Rust工具链
15-
- name: Setup Rust
16-
uses: actions-rs/toolchain@v1
17-
with:
18-
toolchain: stable
19-
profile: minimal
20-
override: true
2111

22-
# 2. 缓存优化(同时缓存cargo和mdbook)
23-
- uses: actions/cache@v3
24-
id: cache
25-
with:
26-
path: |
27-
~/.cargo/bin
28-
~/.cargo/registry/index
29-
~/.cargo/registry/cache
30-
~/.cargo/git/db
31-
target
32-
key: ${{ runner.os }}-cargo-${{ hashFiles('​**​/Cargo.toml') }}
33-
restore-keys: |
34-
${{ runner.os }}-cargo-
35-
36-
# 3. 通过cargo安装mdBook
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v2
15+
3716
- name: Install mdBook
38-
run: |
39-
if [ -f ~/.cargo/bin/mdbook ]; then
40-
echo "mdBook found in cache"
41-
else
42-
cargo install mdbook --version 0.4.34 --locked
43-
fi
44-
45-
# 4. 构建书籍(带错误重试)
46-
- name: Build book
47-
run: |
48-
retry_count=0
49-
max_retries=3
50-
until mdbook build || [ $retry_count -eq $max_retries ]
51-
do
52-
retry_count=$((retry_count+1))
53-
echo "Retrying build (attempt $retry_count)..."
54-
sleep 5
55-
done
17+
run: cargo install mdbook
5618

57-
# 处理中文路径问题
58-
find book -type f -name "*.html" -exec sed -i 's/%20/-/g; s/ /-/g' {} \;
19+
- name: Build the book
20+
run: mdbook build docs
5921

60-
# 5. 部署到GitHub Pages
61-
- name: Deploy
22+
- name: Deploy to GitHub Pages
6223
uses: peaceiris/actions-gh-pages@v3
63-
if: success()
6424
with:
6525
github_token: ${{ secrets.GITHUB_TOKEN }}
66-
publish_dir: ./book
67-
keep_files: false
26+
publish_branch: gh-pages
27+
publish_dir: ./book

book.toml

Lines changed: 2 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,6 @@
11
[book]
2-
title = "具身智能系统开发与实践"
32
authors = ["OpenCamp训练营团队"]
4-
language = "zh-CN"
3+
language = "chinese"
54
multilingual = false
65
src = "src"
7-
build-dir = "target/book"
8-
default-theme = "coal" # 深色主题更适合技术文档
9-
preferred-dark-theme = "navy"
10-
git-repository-url = "https://github.com/opencamp-cn/embodied-intelligence-book"
11-
edit-url-template = "https://github.com/opencamp-cn/embodied-intelligence-book/edit/main/{path}"
12-
13-
[output.html]
14-
mathjax-support = true
15-
additional-css = ["theme/custom.css"]
16-
additional-js = [
17-
"theme/mermaid.min.js",
18-
"theme/copy-code.js"
19-
]
20-
no-section-label = true # 禁用自动生成的章节编号
21-
git-repository-icon = "github"
22-
git-repository-url = "https://github.com/opencamp-cn/embodied-intelligence-book"
23-
site-url = "https://opencamp-cn.github.io/embodied-intelligence-book/"
24-
default-theme = "rust"
25-
preferred-dark-theme = "coal"
26-
curly-quotes = true # 中文引号优化
27-
copy-fonts = true
28-
29-
# 搜索配置(支持中文)
30-
[output.html.search]
31-
limit-results = 20
32-
use-boolean-and = true
33-
boost-title = 2
34-
boost-hierarchy = 1
35-
boost-paragraph = 1
36-
expand = true
37-
heading-split-level = 3
38-
39-
# 打印优化
40-
[output.print]
41-
enable = true
42-
prefer-page-breaks = true
43-
44-
# 插件配置
45-
[preprocessor.links]
46-
render-external-links = true
47-
48-
[preprocessor.mermaid]
49-
command = "mdbook-mermaid"
50-
version = "0.12.0"
51-
52-
[preprocessor.katex]
53-
macros = {
54-
"\\RR": "\\mathbb{R}",
55-
"\\grad": "\\nabla",
56-
"\\argmax": "\\operatorname*{arg\\,max}",
57-
"\\softmax": "\\operatorname{softmax}"
58-
}
59-
60-
# 必须添加的插件声明
61-
[preprocessor.katex.command]
62-
version = "0.3.0"
63-
64-
# Rust代码高亮增强
65-
[rust]
66-
edition = "2021"
67-
code-line-numbers = true
68-
dependencies = [
69-
{ name = "serde", version = "1.0", features = ["derive"] }
70-
]
71-
72-
[build]
73-
extra-watch-dirs = ["theme", "examples"]
74-
create-missing = true # 自动创建缺失章节
6+
title = "具身智能系统开发与实践"

0 commit comments

Comments
 (0)