From 2e3a3cc646d8c273ef1bcd78f7aa914d3fc3cf3b Mon Sep 17 00:00:00 2001 From: TurtleRuss Date: Tue, 14 Apr 2026 09:56:45 +0800 Subject: [PATCH] feat(docs): add mdbook support (#313) --- .github/workflows/mdbook.yml | 46 ++++++++++++++++++++++++++++++++++++ .gitignore | 1 + README.md | 24 +++++++++++++++++++ book.toml | 10 ++++++++ 4 files changed, 81 insertions(+) create mode 100644 .github/workflows/mdbook.yml create mode 100644 .gitignore create mode 100644 book.toml diff --git a/.github/workflows/mdbook.yml b/.github/workflows/mdbook.yml new file mode 100644 index 0000000..9969b76 --- /dev/null +++ b/.github/workflows/mdbook.yml @@ -0,0 +1,46 @@ +name: mdBook + +on: + push: + branches: + - master + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: mdbook-pages + cancel-in-progress: true + +jobs: + deploy: + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Pages + uses: actions/configure-pages@v5 + with: + enablement: true + + - name: Install mdBook + run: cargo install mdbook --locked + + - name: Build book + run: mdbook build + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: book + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0067d87 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/book/ diff --git a/README.md b/README.md index 4d71cde..8088e41 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,30 @@ **目的很简单** - 分享我对 Linux 内核机理的一些浅见,帮助读者理解 Linux 内核机理和其他底层内容。从 [这里](https://github.com/hust-open-atom-club/linux-insides-zh/blob/master/SUMMARY.md) 开始阅读这本书吧。 +## 使用 mdBook 构建 + +仓库已经支持直接使用 `mdBook` 构建网页书籍。 + +安装: + +```bash +cargo install mdbook --locked +``` + +构建: + +```bash +mdbook build +``` + +本地预览: + +```bash +mdbook serve --open +``` + +生成结果位于 `book/` 目录。仓库同时提供了 GitHub Actions 工作流,在 `master` 分支更新后自动构建并部署 GitHub Pages。 + **问题/建议**: 如有相关问题或建议,请提交 issue。一方面,对于英文原文问题,请在上游仓库 - [linux-insides](https://github.com/0xAX/linux-insides) 中提交 issue;另一方面,对于中文翻译问题,请在下游仓库 - [linux-insides-zh](https://github.com/hust-open-atom-club/linux-insides-zh) 中提交 issue。 ## 贡献 diff --git a/book.toml b/book.toml new file mode 100644 index 0000000..3231f58 --- /dev/null +++ b/book.toml @@ -0,0 +1,10 @@ +[book] +title = "Linux 内核揭秘" +language = "zh-CN" +src = "." + +[output.html] +default-theme = "light" +preferred-dark-theme = "navy" +git-repository-url = "https://github.com/hust-open-atom-club/linux-insides-zh" +site-url = "/linux-insides-zh/"