summaryrefslogtreecommitdiff
path: root/gulpfile.js
diff options
context:
space:
mode:
Diffstat (limited to 'gulpfile.js')
-rw-r--r--gulpfile.js42
1 files changed, 38 insertions, 4 deletions
diff --git a/gulpfile.js b/gulpfile.js
index 612ebee..981f289 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,8 +103,9 @@
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'),
104 'mtime': stat.mtime, 107 'mtime': stat.mtime,
105 'path': 'posts/' + files[i] 108 'path': 'posts/' + files[i].replace('.hbs', '.html')
106 }); 109 });
107 } catch (e) { 110 } catch (e) {
108 // Do nothing 111 // Do nothing
@@ -114,6 +117,12 @@
114 return posts; 117 return posts;
115 } 118 }
116 119
120 function performTemplateChange(content) {
121 var file = dir.src + '/templates/post.hbs';
122 var stat = fs.statSync(file);
123 return fs.readFileSync(file, {'encoding': 'utf-8'});
124 }
125
117 /** 126 /**
118 * Clean the output directory. 127 * Clean the output directory.
119 * 128 *
@@ -211,7 +220,7 @@
211 /** 220 /**
212 * Package the handlebars files. 221 * Package the handlebars files.
213 */ 222 */
214 gulp.task('package:posts', function () { 223 gulp.task('package:postindex', function () {
215 224
216 var templateData = { 225 var templateData = {
217 'posts': buildPostManifest(), 226 'posts': buildPostManifest(),
@@ -227,6 +236,30 @@
227 .pipe(gulp.dest(dir.dist)); 236 .pipe(gulp.dest(dir.dist));
228 }); 237 });
229 238
239 gulp.task('package:posts', function () {
240
241 var templateData = {
242 'author': packageJson.author
243 };
244
245 // Automatically build the site list.
246 return gulp.src(dir.src + '/posts/*.hbs', {'base': dir.src})
247 .pipe(data(function(file) {
248 var stat = fs.statSync(file.path);
249 var $ = cheerio.load(fs.readFileSync(file.path));
250 return {
251 'title': $("head title").text(),
252 'description': $("head meta[name='description']").attr('content'),
253 'body': $("body").html(),
254 }}))
255 .pipe(change(performTemplateChange))
256 .pipe(handlebars(templateData, handlebarsConfig))
257 .pipe(rename(function (path) {
258 path.extname = ".html";
259 }))
260 .pipe(gulp.dest(dir.dist));
261 });
262
230 /** 263 /**
231 * Copy the HTML files into the dist folder. 264 * Copy the HTML files into the dist folder.
232 */ 265 */
@@ -295,8 +328,9 @@
295 /** 328 /**
296 * Package the entire site into the dist folder. 329 * Package the entire site into the dist folder.
297 */ 330 */
298 gulp.task('package', ['package:html', 'package:talks', 'package:posts', 331 gulp.task('package', ['package:html', 'package:talks',
299 'package:libs', 332 'package:posts',
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 () {