-
Notifications
You must be signed in to change notification settings - Fork 15
/
gulpfile.js
86 lines (70 loc) · 3.21 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
var gulp = require('gulp'),
gulpLoadPlugins = require('gulp-load-plugins'),
plugins = gulpLoadPlugins();
var cdnUrl = [
[ '<link rel=\"stylesheet\" rev=\"stylesheet\" href=\"assets/fonts.css\" type=\"text/css\" media=\"all\" />', '' ],
[ 'assets/', 'https://s.anw.red/anyway.post/' ]
];
var fontUrl = [
[ 'fonts/', 'https://s.anw.red/anyway.post/' ]
];
gulp.task('build', function() {
gulp.src(['index.html','result.php'])
.pipe(plugins.fontSpider({ignore: ['assets/fonts.css']}));
gulp.src(['*.html','*.php'])
.pipe(plugins.batchReplace(cdnUrl))
.pipe(plugins.changed('builds'))
.pipe(gulp.dest('builds'));
gulp.src('assets/fonts/*.*')
.pipe(plugins.changed('builds'))
.pipe(gulp.dest('builds'));
gulp.src('assets/*.svg')
.pipe(plugins.svgo())
.pipe(plugins.changed('builds'))
.pipe(gulp.dest('builds'));
gulp.src(['assets/*.css','!assets/*.min.css'])
.pipe(plugins.concat('main.css'))
.pipe(plugins.batchReplace(fontUrl))
.pipe(plugins.cleanCss({compatibility: 'ie8'}))
.pipe(plugins.changed('builds'))
.pipe(gulp.dest('builds'));
});
gulp.task('default', function() {
var mds = require('markdown-styles'),
path = require('path');
mds.render(mds.resolveArgs({
input: path.normalize(process.cwd() + '/Posts/Markdown'),
output: path.normalize(process.cwd() + '/Posts/Temp'),
layout: path.normalize(process.cwd() + '/Posts/Theme'),
}), function() {
console.log('HTML 转换完成~');
});
var htmlTheme = [
[ '<a href', '<a style=\"text-decoration:none;color:#333 !important;border-bottom:2px solid #ffe324;\" href' ],
[ '<p', '<div style=\"color:#555;font-size:15px;line-height:1.7;margin-top:1em;margin-bottom:1em;\"' ],
[ '</p>', '</div>' ],
[ '<img ', '<img width=\"100%\" style=\"max-width:100%;\" ' ],
[ '<ul', '<div style=\"color:#555;font-size:15px;line-height:1.7;margin-top:.5em;margin-bottom:.5em;\"' ],
[ '</ul>', '</div>' ],
[ '<ol', '<div style=\"color:#555;font-size:15px;line-height:1.7;margin-top:.5em;margin-bottom:.5em;\"' ],
[ '</ol>', '</div>' ],
[ '<li>', '<table style=\"border:0;border-collapse:collapse;margin-bottom:.3em;color:#333;\"><tr><td style=\"font-size:15px;width:.5em;color:#777;vertical-align:top;\">·</td><td style=\"font-family:AnywayType,sans-serif;font-size:15px;\">' ],
[ '</li>', '</td></tr></table>' ],
[ '<hr>', '' ],
[ '<blockquote', '<div style=\"border-left:4px solid #ffe324; padding-left:.6em;margin-left:1rem;font-weight:300;font-style:normal;\"' ],
[ '</blockquote>', '</div>' ],
[ '<h1', '<div style=\"margin: 5em 0 .7em;background-color:#ffe324;width:.8em;height:.8em;\"></div><div style=\"color:#333 !important;font-weight:700;font-size:1.25em;margin-top:0em;margin-bottom:0;\"' ],
[ '</h1>', '</div>' ],
[ '<h2', '<div style=\"color:#333 !important;font-weight:700;font-size:1em;margin-top:2.5em;margin-bottom:.1em;\"' ],
[ '</h2>', '</div>' ],
[ '<h3>', '<div style=\"font-weight:700;font-size:15px;margin-top:0;margin-bottom:1.2em;line-height:1.38;\">→ ' ],
[ '</h3>', '</div>' ],
['<em>|NAME|</em>','*|NAME|*']
];
return gulp.src('Posts/Temp/*.html')
.pipe(plugins.batchReplace(htmlTheme))
.pipe(gulp.dest('Posts/HTML/'));
});
gulp.task('watch', function() {
gulp.watch(['*','*/*'], ['default']);
});