@@ -10,7 +10,56 @@ sidebarDepth: 3
10
10
** 除了修改元数据字段(即除 ` steps ` 以外),强烈建议不要手动编辑此文件** 。我们推荐直接在浏览器编辑器中书写教程。
11
11
:::
12
12
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` 等等)
14
63
15
64
` ` ` yaml
16
65
name: 教程名称
@@ -22,12 +71,14 @@ created: "2019/7/13 20:46:25"
22
71
updated: "2010/7/20 09:23:10"
23
72
github: https://github.com/username/repository
24
73
splits:
25
- - name : 教程名称(1)
74
+ - name: 教程第一部分的标题
26
75
description: 这是教程第一部分的描述
76
+ cover: tuture-assets/cover-1.png
27
77
start: ae05546
28
78
end: ae05546
29
- - name : 教程名称(2)
79
+ - name: 教程第二部分的标题
30
80
description: 这是教程第二部分的描述
81
+ cover: tuture-assets/cover-2.png
31
82
start: a45bec1
32
83
end: a45bec1
33
84
steps:
@@ -39,16 +90,6 @@ steps:
39
90
diff:
40
91
- file: 发生变化的文件 A
41
92
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
52
93
explain:
53
94
pre: 修改此部分 A 之前的介绍文字
54
95
- file: 发生变化的文件 B
@@ -108,6 +149,12 @@ steps:
108
149
109
150
这能帮助人们更快地发现你的教程并且产生兴趣。
110
151
152
+ # ## `cover`
153
+
154
+ 教程的封面。
155
+
156
+ 可以是网址链接(例如 `https://example.com/image.png`),也可以是本地指向图片的路径(例如 `tuture-assets/image.png`)。
157
+
111
158
# ## `created`
112
159
113
160
教程创建时间。
@@ -136,6 +183,12 @@ steps:
136
183
137
184
如果给出定义,那么全局的 `description` 将被覆盖。
138
185
186
+ # ### `cover`
187
+
188
+ 教程的封面。
189
+
190
+ 如果给出定义,那么全局的 `cover` 将被覆盖。
191
+
139
192
# ### `start` <span class="required">required</span>
140
193
141
194
这一部分的起始提交 ID。
@@ -223,32 +276,40 @@ interface Explain {
223
276
224
277
interface Diff {
225
278
file: string;
226
- display?: boolean;
227
279
explain?: Explain;
280
+ display?: boolean;
228
281
}
229
282
230
- interface Step {
283
+ interface TutureMeta {
231
284
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;
236
292
}
237
293
238
- export interface Split {
294
+ interface Split extends TutureMeta {
239
295
start: string;
240
296
end: string;
241
- name?: string;
242
- description?: string;
243
297
}
244
298
245
- interface Tuture {
299
+ interface Commit {
246
300
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;
249
312
splits?: Split[];
250
- created?: Date;
251
- updated?: Date;
252
313
steps: Step[];
253
314
}
254
315
```
0 commit comments