Skip to content

Commit 58add39

Browse files
committed
从docsify迁移至vitepress
1 parent 7f2396a commit 58add39

14 files changed

Lines changed: 4122 additions & 90 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# 构建 VitePress 站点并将其部署到 GitHub Pages 的示例工作流程
2+
#
3+
name: Deploy VitePress site to Pages
4+
5+
on:
6+
# 在针对 `main` 分支的推送上运行。如果你
7+
# 使用 `master` 分支作为默认分支,请将其更改为 `master`
8+
push:
9+
branches: [main]
10+
11+
# 允许你从 Actions 选项卡手动运行此工作流程
12+
workflow_dispatch:
13+
14+
# 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages
15+
permissions:
16+
contents: read
17+
pages: write
18+
id-token: write
19+
20+
# 只允许同时进行一次部署,跳过正在运行和最新队列之间的运行队列
21+
# 但是,不要取消正在进行的运行,因为我们希望允许这些生产部署完成
22+
concurrency:
23+
group: pages
24+
cancel-in-progress: false
25+
26+
jobs:
27+
# 构建工作
28+
build:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v5
33+
with:
34+
fetch-depth: 0 # 如果未启用 lastUpdated,则不需要
35+
# - uses: pnpm/action-setup@v4 # 如果使用 pnpm,请取消此区域注释
36+
# with:
37+
# version: 9
38+
# - uses: oven-sh/setup-bun@v1 # 如果使用 Bun,请取消注释
39+
- name: Setup Node
40+
uses: actions/setup-node@v6
41+
with:
42+
node-version: 24
43+
cache: npm # 或 pnpm / yarn
44+
- name: Setup Pages
45+
uses: actions/configure-pages@v4
46+
- name: Install dependencies
47+
run: npm ci # 或 pnpm install / yarn install / bun install
48+
- name: Build with VitePress
49+
run: npm run docs:build # 或 pnpm docs:build / yarn docs:build / bun run docs:build
50+
- name: Upload artifact
51+
uses: actions/upload-pages-artifact@v3
52+
with:
53+
path: docs/.vitepress/dist
54+
55+
# 部署工作
56+
deploy:
57+
environment:
58+
name: github-pages
59+
url: ${{ steps.deployment.outputs.page_url }}
60+
needs: build
61+
runs-on: ubuntu-latest
62+
name: Deploy
63+
steps:
64+
- name: Deploy to GitHub Pages
65+
id: deployment
66+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,3 @@
1-
# Logs
2-
logs
3-
*.log
4-
5-
# Runtime data
6-
pids
7-
*.pid
8-
*.seed
9-
10-
# Directory for instrumented libs generated by jscoverage/JSCover
11-
lib-cov
12-
13-
# Coverage directory used by tools like istanbul
14-
coverage
15-
16-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17-
.grunt
18-
19-
# Compiled binary addons (http://nodejs.org/api/addons.html)
20-
build/Release
21-
22-
# Dependency directory
23-
# Deployed apps should consider commenting this line out:
24-
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
25-
node_modules
26-
27-
_book/
28-
book.pdf
29-
book.epub
30-
book.mobi
31-
32-
.idea
1+
node_modules/
2+
docs/.vitepress/dist
3+
docs/.vitepress/cache

docs/.nojekyll

Whitespace-only changes.

docs/.vitepress/config.mts

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import { defineConfig } from 'vitepress'
2+
import mathjax3 from 'markdown-it-mathjax3';
3+
// https://vitepress.dev/reference/site-config
4+
5+
// 1. 获取环境变量并判断
6+
// 如果环境变量 EDGEONE 等于 '1',说明在 EdgeOne 环境,使用根路径 '/'
7+
// 否则默认是 GitHub Pages 环境,使用仓库子路径 '/easy-vecdb/'
8+
const isEdgeOne = process.env.EDGEONE === '1'
9+
const baseConfig = isEdgeOne ? '/' : '/pumpkin-book/'
10+
11+
export default defineConfig({
12+
lang: 'zh-CN',
13+
title: "南瓜书(pumpkin-book)",
14+
description: "《机器学习》(西瓜书)公式详解",
15+
base: baseConfig,
16+
markdown: {
17+
config(md) {
18+
md.use(mathjax3, {
19+
tex: {
20+
macros: {
21+
textcircled: ['\\enclose{circle}{#1}', 1]
22+
}
23+
}
24+
})
25+
}
26+
},
27+
themeConfig: {
28+
// https://vitepress.dev/reference/default-theme-config
29+
logo: '/pumpkin-logo.png',
30+
nav: [
31+
{ text: '纸质版勘误表', link: '/errata' },
32+
{ text: 'PDF版本下载', link: 'https://github.com/datawhalechina/pumpkin-book/releases' },
33+
],
34+
search: {
35+
provider: 'local',
36+
options: {
37+
translations: {
38+
button: {
39+
buttonText: '搜索文档',
40+
buttonAriaLabel: '搜索文档'
41+
},
42+
modal: {
43+
noResultsText: '无法找到相关结果',
44+
resetButtonTitle: '清除查询条件',
45+
footer: {
46+
selectText: '选择',
47+
navigateText: '切换'
48+
}
49+
}
50+
}
51+
}
52+
},
53+
sidebar: [
54+
{
55+
items: [
56+
{ text: '第1章 绪论', link: '/chapter1/chapter1' },
57+
{ text: '第2章 模型评估', link: 'chapter2/chapter2' },
58+
{ text: '第3章 线性模型', link: 'chapter3/chapter3' },
59+
{ text: '第4章 决策树', link: 'chapter4/chapter4' },
60+
{ text: '第5章 神经网络', link: 'chapter5/chapter5' },
61+
{ text: '第6章 支持向量机', link: 'chapter6/chapter6' },
62+
{ text: '第7章 贝叶斯分类器', link: 'chapter7/chapter7' },
63+
{ text: '第8章 集成学习', link: 'chapter8/chapter8' },
64+
{ text: '第9章 聚类', link: 'chapter9/chapter9' },
65+
{ text: '第10章 降维与度量学习', link: 'chapter10/chapter10' },
66+
{ text: '第11章 特征选择与稀疏学习', link: 'chapter11/chapter11' },
67+
{ text: '第12章 计算学习理论', link: 'chapter12/chapter12' },
68+
{ text: '第13章 半监督学习', link: 'chapter13/chapter13' },
69+
{ text: '第14章 概率图模型', link: 'chapter14/chapter14' },
70+
{ text: '第15章 规则学习', link: 'chapter15/chapter15' },
71+
{ text: '第16章 强化学习', link: 'chapter16/chapter16' },
72+
]
73+
}
74+
],
75+
76+
socialLinks: [
77+
{ icon: 'github', link: 'https://github.com/datawhalechina/pumpkin-book' }
78+
],
79+
80+
editLink: {
81+
pattern: 'https://github.com/datawhalechina/pumpkin-book/blob/main/docs/:path'
82+
},
83+
84+
footer: {
85+
message: '<a href="https://beian.miit.gov.cn/" target="_blank">京ICP备2026002630号-1</a>',
86+
copyright: '本作品采用 <a href="http://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议(CC BY-NC-SA 4.0)</a> 进行许可'
87+
}
88+
}
89+
})

0 commit comments

Comments
 (0)