Skip to content

Commit 5428648

Browse files
authored
Merge pull request #20 from InvolutionHell/feat/CICD
添加自动化脚本, 当用户提交文档的时候优先把图片放到和MDX同一级
2 parents 434e4cc + 484cf8b commit 5428648

12 files changed

Lines changed: 491 additions & 24 deletions

File tree

.github/workflows/content-check.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,12 @@ jobs:
3535
cache: "pnpm"
3636

3737
- run: pnpm install --frozen-lockfile
38+
# Non-blocking image migration + lint (visibility only)
39+
- name: Migrate images next to MDX (check only)
40+
run: pnpm migrate:images || echo "[warn] migrate:images failed (non-blocking)"
41+
42+
- name: Lint image references (non-blocking)
43+
run: pnpm lint:images || echo "[warn] image lint found issues (non-blocking)"
44+
3845
# Build the site to validate MDX and docs using Fumadocs
3946
- run: pnpm build

.husky/pre-commit

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1+
# 1) 将 /images/* 文章图片就近复制并更新引用
2+
pnpm migrate:images || exit 1
3+
4+
# 将迁移后的变更加入暂存,确保本次提交包含更新
5+
git add -A
6+
7+
# 2) 校验图片路径与命名(不合规则阻止提交)
8+
pnpm lint:images || exit 1
9+
10+
# 3) 其余按 lint-staged 处理(如 Prettier)
111
pnpm exec lint-staged

CONTRIBUTING.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ touch docs/computer-science/data-structures/new-topic/index.mdx
3030

3131
使用 Markdown/MDX 编写文章:
3232

33-
````mdx
33+
```mdx
3434
---
3535
title: "文章标题"
3636
description: "文章简短描述"
@@ -51,28 +51,16 @@ tags:
5151
更多内容...
5252

5353
## 代码示例
54-
55-
```javascript
56-
// 你的代码
57-
function example() {
58-
return "Hello World!";
59-
}
6054
```
61-
````
62-
63-
## 总结
64-
65-
文章总结...
66-
67-
````
6855

6956
### 步骤4:测试修改
7057

7158
使用 Fumadocs 验证内容:
7259

7360
```bash
7461
pnpm build
75-
````
62+
pnpm migrate:images # 迁移图片脚本
63+
```
7664

7765
此命令将:
7866

@@ -141,6 +129,17 @@ npm dev
141129
## 📚 文档规范
142130

143131
所有文档放在 `docs/` 目录。
132+
图片需要放在 被引用的文档的同名`assets`目录下(正常情况下您不应该关心这个, 该项目有自动脚本来移动图片), 例如:
133+
docxA 引用了 imgA 图片, 那么他们的文档结构应该是 `docxA.assets/imgA`:
134+
135+
```md
136+
docsA.mdx
137+
docsA.assets/
138+
imgA
139+
```
140+
141+
![img](public/readme_docs_structure.png)
142+
144143
每个文档都需要一个 Frontmatter,例如:
145144

146145
```md

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,17 @@ pnpm dev
9090
pnpm dev # 启动开发服务器
9191
pnpm build # 构建生产版本
9292
pnpm start # 启动生产服务器
93+
pnpm postinstall
94+
pnpm lint:images # 检查图片符合规则
95+
pnpm migrate:images # 迁移图片
96+
```
9397

94-
# 内容
98+
## 图片管理规范(简要)
9599

100+
自动化脚本会移动您引用的图片到 MDX 同目录下, 遵循以下规则:
96101

97-
# 导出
98-
pnpm export # 导出静态站点到 /out 目录
99-
```
102+
- 存放:与 MDX 同目录的 `./<basename>.assets/` 中。
103+
- 例:`foo.mdx``./foo.assets/<img>.png``index.mdx``./index.assets/<img>.png`
104+
- 引用:相对路径 `![](./<basename>.assets/<img>.png)`
105+
- 自动化:提交时自动迁移并改引用;图片 Lint 只提示不拦截提交。
106+
- 共享:站点级用 `/images/site/*`、组件演示用 `/images/components/<name>/*`;多文档共用的图片可保留 `/images/...`

public/images/word/word-img-03.png renamed to app/docs/ai/multimodal/llava/index.assets/word-img-03.png

File renamed without changes.

public/images/word/word-img-04.png renamed to app/docs/ai/multimodal/llava/index.assets/word-img-04.png

File renamed without changes.

public/images/word/word-img-05.png renamed to app/docs/ai/multimodal/llava/index.assets/word-img-05.png

File renamed without changes.

app/docs/ai/multimodal/llava/index.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
---
1+
---
22
title: "LLaVA"
33
description: "LLaVA多模态大模型框架:架构解析、CLIP基础、论文精读、复现实践"
44
date: "2025-01-27"
@@ -12,7 +12,7 @@ tags:
1212

1313
LLaVA (Large Language and Vision Assistant) 是多模态大模型的开创性框架,开启了视觉指令调优的新范式。
1414

15-
![](/images/word/word-img-03.png)
15+
![](index.assets/word-img-03.png)
1616

1717
## 核心架构
1818

@@ -22,9 +22,9 @@ LLaVA (Large Language and Vision Assistant) 是多模态大模型的开创性框
2222
ViT视觉编码器 → 投影层跨模态对齐 → LLM语言生成
2323
```
2424

25-
![](/images/word/word-img-04.png)
25+
![](index.assets/word-img-04.png)
2626

27-
![](/images/word/word-img-05.png)
27+
![](index.assets/word-img-05.png)
2828

2929
### 技术特点
3030

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"build": "next build",
88
"start": "next start",
99
"postinstall": "fumadocs-mdx",
10-
"prepare": "husky"
10+
"prepare": "husky",
11+
"lint:images": "node scripts/check-images.mjs",
12+
"migrate:images": "node scripts/move-doc-images.mjs"
1113
},
1214
"dependencies": {
1315
"@types/mdx": "^2.0.13",

public/readme_docs_structure.png

10.3 KB
Loading

0 commit comments

Comments
 (0)