Commit c66c3c3d authored by wu-lee's avatar wu-lee

metalsmith.js - sort posts by creation date

parent 444598b5
......@@ -100,6 +100,15 @@ function collectionIndexes(opts = {}) {
const gitMeta = git.fileInfoSync();
// A function to compare posts by git.first.authored
function postCreation(a, b) {
a = gitMeta[a.path];
b = gitMeta[b.path];
a = a? a.first.authored : 0;
b = b? b.first.authored : 0;
return b - a;
}
// Dummy metadata to omit voluminous/circular crap fields
function elideMeta(meta) {
return {
......@@ -128,6 +137,7 @@ module.exports = () => {
.use(collections({
posts: {
pattern: 'posts/*.md',
sortBy: postCreation,
},
}))
.use(collectionIndexes({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment