-
Notifications
You must be signed in to change notification settings - Fork 0
/
book.json5
189 lines (189 loc) · 5.49 KB
/
book.json5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
{
// 定义模板
// Define templates
"templates": [
{
"template-path": "en-us.html",
"catalogue-path": "en-us/catalogue.json",
"lang": "en-us"
},
{
"template-path": "zh-cn.html",
"catalogue-path": "zh-cn/catalogue.json",
"lang": "zh-cn"
}
],
// 定义不同文件的处理方式
// Define different file processing methods
"workflows": [
// pom.xml,book.json这些配置文件直接忽略,我们不需要它们
// pom.xml, book.json and other configuration files are ignored, we don't need them.
{
"conditions": [
{
"or": [
{
"filename": "(.*pom.xml)|(.*book.json5)|(.*FrostRender-{0,9}.*)|(catalogue.json)"
},
{
"path": "(.*target[/\\\\].*)"
}
]
}
],
"steps": [
"ignore"
]
},
// js文件,除了min.js(已经编译完的文件)之外,都需要进行优化编译
// js files, except min.js (already compiled files), need to be optimized and compiled
{
"conditions": [
{
// 正则表达式,匹配所有js文件,但是排除了min.js
"filename": ".*(?<!\\.min)\\.js$"
}
],
"steps": [
"fetch-file",
{
"id": "compile-js",
"args": {
"input-mode": "es12",
// Android 6+
"output-mode": "es7"
}
}
]
},
// markdown文件处理
// markdown file processing
{
"conditions": [
{
"filename": ".*\\.md$"
}
],
"steps": [
"fetch-file",
// 从文件内容中摘取标题
// Extract title from file content
{
"id": "collect-title",
"args": {
// 第一个group中的内容作为标题
// The content of the first group is used as the title
"title-regexp": "(?<!#)# (.+)(?= {0,2}[\\r\\n]{1,2})"
}
},
// 修补markdown链接中错误的相对位置
// Repair the wrong relative position in the Markdown link
"patch-link",
// 将markdown内容渲染为html
// Render markdown content as html
{
"id": "markdown",
"args": {
"css-classes": {
"h1": "mdui-text-color-theme",
"h2": "mdui-text-color-theme",
"h3": "mdui-text-color-theme",
"table": "mdui-table mdui-table-hoverable"
},
// 将会以mdui兼容的方式渲染
// Will be rendered in a mdui compatible way
"mode": "mdui-compatible"
}
},
// rename .md into .html
{
"id": "rename-file",
"args": {
"regexp": "\\.md$",
"replacement": ".html",
"rename-path": false
}
},
// 收集多语言链接
// Collect multi-language links
{
"id": "collector-multi-lang-link",
"args": {
// 每个文件的路径上符合正则表达式的部分将被替换为languages数组中的内容,然后进行排列组合
// The part of the path of each file that matches the regular expression will be replaced with the content of the languages array, and then the permutation combination will be performed.
"regexp": "([a-z]{2}-[a-z]{2})(?=[/\\\\])",
// 最终信息将被收集为multi-language-links变量以供模板调用
// The final information will be collected as the multi-language-links variable for template calls
"languages": [
"zh-cn",
"en-us"
]
}
},
// 将渲染出来的html应用到模板中
// Apply rendered html to template
{
"id": "template",
"args": {
"template": {
// 第一个group中的内容加上.html作为模板的名称
// The content of the first group plus .html is used as the template name
"regexp": "([a-z]{2}-[a-z]{2})[/\\\\]",
"insert-after": ".html"
},
// 我们将用之前渲染的内容替换掉模板中的%md%
// We will replace the %md% in the template with the previously rendered content
"embed-content-placeholder": "md"
}
},
// 添加目录到html中
// Add a table of contents to html
{
"id": "catalogue",
"args": {
"css-classes": {
"ol": "category-sub",
"li": "category-item",
"a": "category-link",
"p": "category-title mdui-text-color-theme"
},
"embed-content-placeholder": "catalogue"
}
}
]
},
// 复制主页
// Copy the index page
{
"conditions": [
{
"filename": ".*index\\.html$"
}
],
"steps": [
"fetch-file",
"patch-link"
]
},
// 压缩图片
// Compress images
{
"conditions": [
{
"filename": ".*\\.(png|jpg|jpeg|gif|bmp)$"
}
],
"steps": [
"fetch-file",
{
"id": "compress-image",
"args": {
// quality: (0, 1) 越小质量越低,体积越小
// quality: (0, 1) The smaller the quality, the smaller the size
"quality": 0.01
}
}
]
}
]
}