-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathscript.js
More file actions
38 lines (29 loc) · 873 Bytes
/
script.js
File metadata and controls
38 lines (29 loc) · 873 Bytes
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
const fs = require("fs");
const srcDir = "../../src/" // 源码目录
const targetDir = "docs/component/" // 目标目录
/**
* 自动创建md文件,写入代码演示
*/
fs.readdir(targetDir, function (err, files) {
if (err) {
return console.error(err);
}
files.forEach(function (file) {
// console.log('file', file);
const preName = file.replace(/.md/g, '')
const content = `<h2>代码演示</h2>
<div class="container-demo-main">
<div class="container-demo-left">
[filename](${srcDir+preName}.html ':include :type=code :fragment=htmldemo')
</div>
<div class="container-demo-right">
[filename](${srcDir+preName}.html ':include width=375 height=667')
</div>`
fs.writeFile(targetDir+file, content, function (err) {
if (err) {
return console.error(err);
}
console.log("写入成功");
});
});
});