-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-index.js
executable file
·50 lines (34 loc) · 1.35 KB
/
generate-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
var pkg = require('./package.json');
var fs = require('fs');
var path = require('path');
module.exports = function() {
var h2 = '<h2 class="banner-client">' + pkg.title + '</h2>';
var h3 = '<h3 class="banner-name">' + pkg.client + '</h3>';
var table = '<div class="table-responsive"><table class="table"><tbody>';
var tr = '<tr><td class="b-top">';
var ENDtr = '</td></tr>';
var SRC_PATH = 'src/banner_list';
var FOLDER = getFolders(SRC_PATH);
function getFolders(dir) {
return fs.readdirSync(dir)
.filter(function() {
return fs.statSync(path.join(dir)).isDirectory();
});
}
var htmlTask = FOLDER.map(function(FOLDER) {
if( FOLDER !== '.DS_Store' ) {
var folderName = FOLDER.replace(/_/g," ");
var links = '';
table += tr;
links += '<a class="pull-left banner-size" href="' + FOLDER + '/index.html" target="_blank">' + folderName + '</a>';
links += '<a class="pull-right zip" href="ZIPS/' + FOLDER + '.zip" target="_blank">ZIP</a>';
links += '<a class="backup_img" href="static/' + FOLDER + '.jpg" target="_blank">Backup Frame</a>';
table += links;
table += ENDtr;
}
});
table += '</tbody></table></div>';
html = h2 + h3 + table;
return html;
return htmlTask;
}