-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
27 lines (25 loc) · 1.01 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
const gulp = require("gulp");
const inject = require('gulp-inject');
gulp.task('linksInject', async function (done) {
gulp.src('./index.html', { allowEmpty: true })
.pipe(inject(
gulp.src(['./animations/**/*.html'], { read: false, allowEmpty: true }), {
transform: function (filepath) {
if (filepath.slice(-5) === '.html') {
let splittedString = filepath.split('/');
if (splittedString.length > 1 && splittedString[2]) {
let titledString = splittedString[2].replace(/-/g, ' ');
titledString = titledString.charAt(0).toUpperCase() + titledString.slice(1)
return '<li><a href="' + filepath.substring(1) + '">' + titledString + '</a></li>';
} else {
return '<li><a href="' + filepath.substring(1) + '">' + filepath + '</a></li>';
}
}
// Use the default transform as fallback:
return inject.transform.apply(inject.transform, arguments);
}
}
))
.pipe(gulp.dest('./'));
done();
});