summaryrefslogtreecommitdiff
path: root/gulpfile.js
diff options
context:
space:
mode:
Diffstat (limited to 'gulpfile.js')
-rw-r--r--gulpfile.js38
1 files changed, 36 insertions, 2 deletions
diff --git a/gulpfile.js b/gulpfile.js
index 612ebee..3f63fa6 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -10,6 +10,8 @@
10 var git = require('gulp-git'); 10 var git = require('gulp-git');
11 var filter = require('gulp-filter'); 11 var filter = require('gulp-filter');
12 var less = require('gulp-less'); 12 var less = require('gulp-less');
13 var data = require('gulp-data');
14 var change = require('gulp-change');
13 var rsync = require('gulp-rsync'); 15 var rsync = require('gulp-rsync');
14 var webserver = require('gulp-webserver'); 16 var webserver = require('gulp-webserver');
15 var streamqueue = require('streamqueue'); 17 var streamqueue = require('streamqueue');
@@ -101,6 +103,8 @@
101 var $ = cheerio.load(fs.readFileSync(file)); 103 var $ = cheerio.load(fs.readFileSync(file));
102 posts.push({ 104 posts.push({
103 'title': $("head title").text(), 105 'title': $("head title").text(),
106 'description': $("head meta[name='description']").attr('content'),
107 'body': $("body").text(),
104 'mtime': stat.mtime, 108 'mtime': stat.mtime,
105 'path': 'posts/' + files[i] 109 'path': 'posts/' + files[i]
106 }); 110 });
@@ -114,6 +118,12 @@
114 return posts; 118 return posts;
115 } 119 }
116 120
121 function performTemplateChange(content) {
122 var file = dir.src + '/templates/post.hbs';
123 var stat = fs.statSync(file);
124 return fs.readFileSync(file, {'encoding': 'utf-8'});
125 }
126
117 /** 127 /**
118 * Clean the output directory. 128 * Clean the output directory.
119 * 129 *
@@ -211,7 +221,7 @@
211 /** 221 /**
212 * Package the handlebars files. 222 * Package the handlebars files.
213 */ 223 */
214 gulp.task('package:posts', function () { 224 gulp.task('package:postindex', function () {
215 225
216 var templateData = { 226 var templateData = {
217 'posts': buildPostManifest(), 227 'posts': buildPostManifest(),
@@ -227,6 +237,30 @@
227 .pipe(gulp.dest(dir.dist)); 237 .pipe(gulp.dest(dir.dist));
228 }); 238 });
229 239
240 gulp.task('package:posts', function () {
241
242 var templateData = {
243 'author': packageJson.author
244 };
245
246 // Automatically build the site list.
247 return gulp.src(dir.src + '/posts/*.html', {'base': dir.src})
248 .pipe(data(function(path) {
249 var stat = fs.statSync(path);
250 var $ = cheerio.load(fs.readFileSync(path));
251 return {
252 'title': $("head title").text(),
253 'description': $("head meta[name='description']").attr('content'),
254 'body': $("body").text(),
255 }}))
256 .pipe(change(performTemplateChange))
257 .pipe(handlebars(templateData, handlebarsConfig))
258 .pipe(rename(function (path) {
259 path.extname = ".html";
260 }))
261 .pipe(gulp.dest(dir.dist));
262 });
263
230 /** 264 /**
231 * Copy the HTML files into the dist folder. 265 * Copy the HTML files into the dist folder.
232 */ 266 */
@@ -296,7 +330,7 @@
296 * Package the entire site into the dist folder. 330 * Package the entire site into the dist folder.
297 */ 331 */
298 gulp.task('package', ['package:html', 'package:talks', 'package:posts', 332 gulp.task('package', ['package:html', 'package:talks', 'package:posts',
299 'package:libs', 333 'package:postindex', 'package:libs',
300 'package:images', 'package:css', 'package:js']); 334 'package:images', 'package:css', 'package:js']);
301 335
302 gulp.task('rsync', function () { 336 gulp.task('rsync', function () {