-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
44 lines (37 loc) · 1 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
const { src, dest, series, watch } = require('gulp')
// Rutas
const dir = {
allFolders: './**/',
allFiles: './**/*',
themes: './themes/*/*.pug',
xml: './themes/*/*.xml'
}
const blogger = {
jsHack: `<textarea id="bjs" readonly hidden></body></textarea>
<script>document.getElementById('bjs').remove()</script></body>`,
tags: /<(b:*[^/>]*)>\s*<\/(b:*[^>]*)>/g,
}
// Plugins
const rename = require("gulp-rename")
const pug = require('gulp-pug')
const replace = require('gulp-replace')
const build = () => {
return src( [dir.themes, `!${dir.allFolders}_*`], { base: "." } )
.pipe(pug({
pretty: true,
basedir: "./"
}))
.pipe(replace(blogger.tags, "<$1/>"))
.pipe(replace('</body>', blogger.jsHack))
.pipe( rename( { extname: '.xml' } ) )
.pipe( dest( './' ) )
}
const watchFiles = () => {
watch(
[ dir.allFiles, `!${dir.xml}` ],
series( build )
);
};
exports.build = build;
exports.watch = watchFiles;
exports.default = watchFiles;