-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
70 lines (61 loc) · 1.52 KB
/
index.js
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
/**
* 创建静态资源文件脚本
* d1y<[email protected]>
*/
const fs = require('fs')
const ghCDN = require('github-to-cdn')
const table = require('markdown-table');
const { execSync } = require('child_process');
/**
* link: https://stackoverflow.com/a/10456644
*/
Object.defineProperty(Array.prototype, 'chunk', {
value: function(chunkSize) {
var array = this;
return [].concat.apply([],
array.map(function(elem, i) {
return i % chunkSize ? [] : [array.slice(i, i + chunkSize)];
})
);
}
});
/**
* 创建静态文件
* @param {String} path 路径
*/
const createCDNFile = (path)=> {
return ghCDN({
username: 'waifu-project',
repo: '18comic-live',
path
})
}
/**
* 创建预览的图片
* @param {String} title 页面
*/
const createPreviewImg = (title)=> {
return createCDNFile(`previews/${ title }.png`)
}
/**
* 预览的所有图片
*/
const previews = fs.readdirSync('previews').map(item=> {
const title = item.split('.')[0]
return createPreviewImg(title)
})
// | | | |
// |----------|:-------------:|------:|
// | ![](./design/1.jpg) | ![](./design/2.jpg) | ![](./design/3.jpg) |
// | ![](./design/4.jpg) | ![](./design/5.jpg) | ![](./design/6.jpg) |
// | ![](./design/7.jpg) | ![](./design/8.jpg) | ![](./design/9.jpg) |
// | ![](./design/10.jpg) | ![](./design/11.jpg) | ![](./design/12.jpg) |
/**
* 打印`table`
*/
const printTable = ()=> {
const len = 4
const chunkList = previews.chunk(len)
console.log(chunkList)
}
printTable()