diff --git a/.eleventy.js b/.eleventy.js index 5996d4e..bfda7a6 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -9,11 +9,15 @@ module.exports = function(eleventyConfig) { eleventyConfig.addLayoutAlias("post", "layouts/post.njk"); eleventyConfig.addFilter("readableDate", dateObj => { - return DateTime.fromJSDate(dateObj).toFormat("dd LLL yyyy"); + return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat("dd LLL yyyy"); }); // Get the first `n` elements of a collection. eleventyConfig.addFilter("head", (array, n) => { + if( n < 0 ) { + return array.slice(n); + } + return array.slice(0, n); }); @@ -24,8 +28,8 @@ module.exports = function(eleventyConfig) { // only content in the `posts/` directory eleventyConfig.addCollection("posts", function(collection) { - return collection.getAllSorted().filter(function(item) { - return item.inputPath.startsWith('./posts'); + return collection.getFilteredByGlob("./posts/*").sort(function(a, b) { + return a.date - b.date; }); }); diff --git a/archive.njk b/archive.njk index 235fd75..61c48d9 100644 --- a/archive.njk +++ b/archive.njk @@ -3,10 +3,10 @@ layout: layouts/home.njk tags: - nav navtitle: Archive -permalink: posts/index.html +permalink: /posts/ --- -
More posts can be found in the blog archive.
+More posts can be found in the archive.
diff --git a/posts/firstpost.md b/posts/firstpost.md index 8bd3e44..666a29a 100644 --- a/posts/firstpost.md +++ b/posts/firstpost.md @@ -1,5 +1,6 @@ --- title: This is my first post. +date: 2018-05-01 tags: - post - another-tag diff --git a/posts/fourthpost.md b/posts/fourthpost.md index 4ac6319..9107bcf 100644 --- a/posts/fourthpost.md +++ b/posts/fourthpost.md @@ -1,5 +1,6 @@ --- title: This is my fourth post. +date: 2018-09-30 tags: second-tag layout: layouts/post.njk --- diff --git a/posts/secondpost.md b/posts/secondpost.md index c7afa5f..bee6fcc 100644 --- a/posts/secondpost.md +++ b/posts/secondpost.md @@ -1,5 +1,6 @@ --- title: This is my second post. +date: 2018-07-04 tags: - post - number-2 diff --git a/posts/thirdpost.md b/posts/thirdpost.md index 04202aa..6688b55 100644 --- a/posts/thirdpost.md +++ b/posts/thirdpost.md @@ -1,5 +1,6 @@ --- title: This is my third post. +date: 2018-08-24 tags: - post - second-tag