This repository has been archived by the owner on Mar 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathgulpfile.js
97 lines (88 loc) · 2.54 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
const gulpStatic = require('gulp-static-gen');
const gulp = require('gulp');
const fs = require('fs');
const path = require('path');
const set = require('lodash.set');
const { Converter } = require('showdown');
const data = {};
const loadData = (folderPath, objectPaths = []) => {
const finalPath = path.resolve(__dirname, folderPath)
const files = fs.readdirSync(finalPath);
files.forEach((file) => {
if (file.indexOf('.') === -1) {
loadData(`${folderPath}/${file}`, [file]);
return;
}
if (file.indexOf('.js') !== -1) {
let paths = [...objectPaths, file.replace('.js', '')]
set(data, paths, require(`${process.cwd()}/${folderPath}/${file}`));
} else {
const conv = new Converter({ metadata: true, tables: true, openLinksInNewWindow: true });
let paths = [...objectPaths, file.replace('.md', '')]
set(data, paths, {
html: conv.makeHtml(fs.readFileSync(
path.resolve(finalPath, file), 'utf-8'
)),
meta: conv.getMetadata(),
});
}
});
}
loadData('src/content')
gulp.task('content', () => {
loadData('src/content')
});
gulpStatic({
customWatchers: [
{ files: './src/content/**/*', tasks: ['content', 'handlebars'] }
],
move: [{
input: './CNAME',
output: './dist'
},
{
input: './pdfs/**/*',
output: './dist/assets/pdfs/'
},
{
input: './src/submissao-de-palestras',
output: './dist/'
},
{
input: './src/grade/**/*',
output: './dist/grade/'
}
],
css: {
input: './src/sass/style.sass',
output: './dist/assets/css',
watch: './src/sass/**/*',
},
hbs: {
batch: ['./src/templates/partials'],
watch: './src/templates/**/*',
multiple: [{
data: data,
input: './src/templates/index.hbs',
output: {
dir: './dist',
name: 'index.html',
}
}]
},
img: {
input: './src/images/**/*',
output: './dist/assets/images',
config: {
interlaced: true,
progressive: true,
optimizationLevel: 5,
svgoPlugins: [{ removeViewBox: true }]
}
},
scripts: {
input: './src/scripts/index.js',
output: './dist/assets/scripts/',
watch: './src/scripts/**/*',
}
});