-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathgulpfile.js
57 lines (48 loc) · 1.5 KB
/
gulpfile.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
var gulp = require('gulp')
var concat = require('gulp-concat')
var handlebars = require('gulp-compile-handlebars')
var rename = require('gulp-rename')
var reps = require('./app/generate-reps/reps.json')
gulp.task('handlebars', function() {
var options = {
helpers: {
ifNull : function(str){
if(str) { return str }
else { return null }
},
socialLink : function(baseUrl, url, icon){
if(url){
return '<a class="card-link" href="' + baseUrl + url + '" target="_blank"><i class="fa fa-icon ' + icon + '" aria-hidden="true"></i></a>';
}else{
return null;
}
},
thisURL : function(first, last){
var url = "https://www.phoneyourrep.com/reps/" + first.toLowerCase() + "_" + last.toLowerCase();
return url;
},
hours : function(hours){
if(hours){
return "Hours: " + hours;
}else{
return "Hours?: Let us know on Twitter @phoneyourrep"
}
}
}
}
for (var i = 0; i < reps.length; i++) {
var rep = reps[i];
var folderName = rep.first.toLowerCase() + '_' + rep.last.toLowerCase()
console.log(folderName);
gulp.src('app/generate-reps/templates/rep.handlebars')
.pipe(handlebars(rep, options))
.pipe(rename('index.html'))
.pipe(gulp.dest('docs/reps/' + folderName + '/'));
}
gulp.src('app/generate-reps/css/*.css')
.pipe(concat('reps.css'))
.pipe(gulp.dest('docs/reps'))
gulp.src('app/images/*')
.pipe(gulp.dest('docs/reps/images'))
});
gulp.task('default', ['handlebars']);