Created
August 16, 2017 14:37
-
-
Save bastibl/8baed642df528b07ee0b68b65069f5d3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//======================================================================= | |
// ARCHIVE | |
//======================================================================= | |
var archive = function() { | |
var posts = []; | |
function bufferContents(file, enc, cb) { | |
var p = { | |
title: file.title, | |
url: file.url, | |
date: file.date | |
}; | |
posts.push(p); | |
cb(); | |
}; | |
function endStream(cb) { | |
posts.sort(function(a, b) { | |
if(a.date < b.date) return 1; | |
if(a.date > b.date) return -1; | |
return 0; | |
}); | |
var f = new File({ | |
cwd: '', | |
base: null, | |
path: 'archive/index.html' | |
}); | |
f.posts = posts; | |
f.description = "Blog Archive of Carriers Everywhere"; | |
this.push(f); | |
cb(); | |
}; | |
return through.obj(bufferContents, endStream); | |
}; | |
gulp.task('archive', function() { | |
return gulp.src('content/_posts/*.md') | |
.pipe(frontmatter({property: 'frontmatter', | |
remove: true})) | |
.pipe(extractMetadata()) | |
.pipe(archive()) | |
.pipe(renderTemplate('archive')) | |
.pipe(debug()) | |
.pipe(gulp.dest('dist')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment