Skip to content

Commit 464a75a

Browse files
committed
Add cover field and update examples
1 parent 9e8e9b1 commit 464a75a

File tree

1 file changed

+88
-27
lines changed

1 file changed

+88
-27
lines changed

reference/tuture-yml-spec.md

+88-27
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,56 @@ sidebarDepth: 3
1010
**除了修改元数据字段(即除 `steps` 以外),强烈建议不要手动编辑此文件**。我们推荐直接在浏览器编辑器中书写教程。
1111
:::
1212

13-
## 一个完整的例子
13+
## 完整的例子
14+
15+
一篇 Tuture 工具写作的教程可能只包含一部分,也可能包含多个部分。下面分别展示这两种情况的完整例子。
16+
17+
### 只包含一部分的教程
18+
19+
```yaml
20+
name: 教程名称
21+
topics:
22+
- JavaScript
23+
- Express
24+
categories:
25+
- 前端
26+
- 入门
27+
description: 这是我写的第一篇教程,快来看看吧
28+
cover: https://example.com/image.png
29+
created: "2019/7/13 20:46:25"
30+
updated: "2010/7/20 09:23:10"
31+
github: https://github.com/username/repository
32+
steps:
33+
- name: 第一步的标题
34+
commit: ae05546
35+
explain:
36+
pre: 此步骤最前面的介绍文字
37+
post: 此步骤最后的总结文字
38+
diff:
39+
- file: 发生变化的文件 A
40+
display: true
41+
explain:
42+
pre: 修改此部分 A 之前的介绍文字
43+
- name: 第二步的标题
44+
commit: a45bec1o
45+
explain:
46+
pre: 此步骤最前面的介绍文字
47+
post: 此步骤最后的总结文字
48+
diff:
49+
- file: 发生变化的文件 B
50+
display: true
51+
explain:
52+
pre: 在修改 B 之前的介绍
53+
- file: 发生变化的文件 C
54+
display: true
55+
explain:
56+
pre: 修改 C 之前的介绍文字
57+
post: 修改 C 之后的解释文字
58+
```
59+
60+
### 包含多部分的教程
61+
62+
与只包含一部分的教程相比,多部分教程主要添加了 `splits` 字段。`splits` 字段是一个数组,每个数组元素对应教程的一部分,并且其中的元数据字段(例如教程名称 `name`、简介 `description`、封面 `cover` 等等)
1463

1564
```yaml
1665
name: 教程名称
@@ -22,12 +71,14 @@ created: "2019/7/13 20:46:25"
2271
updated: "2010/7/20 09:23:10"
2372
github: https://github.com/username/repository
2473
splits:
25-
- name: 教程名称(1)
74+
- name: 教程第一部分的标题
2675
description: 这是教程第一部分的描述
76+
cover: tuture-assets/cover-1.png
2777
start: ae05546
2878
end: ae05546
29-
- name: 教程名称(2)
79+
- name: 教程第二部分的标题
3080
description: 这是教程第二部分的描述
81+
cover: tuture-assets/cover-2.png
3182
start: a45bec1
3283
end: a45bec1
3384
steps:
@@ -39,16 +90,6 @@ steps:
3990
diff:
4091
- file: 发生变化的文件 A
4192
display: true
42-
section:
43-
start: 1
44-
end: 9
45-
explain:
46-
pre: 修改此部分 A 之前的介绍文字
47-
- file: 发生变化的文件 A
48-
display: true
49-
section:
50-
start: 10
51-
end: 20
5293
explain:
5394
pre: 修改此部分 A 之前的介绍文字
5495
- file: 发生变化的文件 B
@@ -108,6 +149,12 @@ steps:
108149

109150
这能帮助人们更快地发现你的教程并且产生兴趣。
110151

152+
### `cover`
153+
154+
教程的封面。
155+
156+
可以是网址链接(例如 `https://example.com/image.png`),也可以是本地指向图片的路径(例如 `tuture-assets/image.png`)。
157+
111158
### `created`
112159

113160
教程创建时间。
@@ -136,6 +183,12 @@ steps:
136183

137184
如果给出定义,那么全局的 `description` 将被覆盖。
138185

186+
#### `cover`
187+
188+
教程的封面。
189+
190+
如果给出定义,那么全局的 `cover` 将被覆盖。
191+
139192
#### `start` <span class="required">required</span>
140193

141194
这一部分的起始提交 ID。
@@ -223,32 +276,40 @@ interface Explain {
223276
224277
interface Diff {
225278
file: string;
226-
display?: boolean;
227279
explain?: Explain;
280+
display?: boolean;
228281
}
229282
230-
interface Step {
283+
interface TutureMeta {
231284
name: string;
232-
commit: string;
233-
explain?: Explain;
234-
outdated?: boolean;
235-
diff: Diff[];
285+
topics?: string[];
286+
categories?: string[];
287+
description?: string;
288+
created?: Date;
289+
updated?: Date;
290+
cover?: string;
291+
github?: string;
236292
}
237293
238-
export interface Split {
294+
interface Split extends TutureMeta {
239295
start: string;
240296
end: string;
241-
name?: string;
242-
description?: string;
243297
}
244298
245-
interface Tuture {
299+
interface Commit {
246300
name: string;
247-
topics?: string[];
248-
description?: string;
301+
commit: string;
302+
}
303+
304+
interface Step extends Commit {
305+
explain?: Explain;
306+
diff: Diff[];
307+
outdated?: boolean;
308+
}
309+
310+
interface Tuture extends TutureMeta {
311+
id?: string;
249312
splits?: Split[];
250-
created?: Date;
251-
updated?: Date;
252313
steps: Step[];
253314
}
254315
```

0 commit comments

Comments
 (0)