From 12273058f634ad34756339cab1b3f01319300487 Mon Sep 17 00:00:00 2001 From: James Walker Date: Mon, 14 Nov 2022 21:05:03 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20add=20dateString=20filter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eleventy.js | 5 ++++- _includes/layouts/default.njk | 7 +++++++ _includes/layouts/post.njk | 10 ++++------ index.njk | 9 +-------- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.eleventy.js b/.eleventy.js index 4b9161b..1ef0d19 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -29,6 +29,10 @@ module.exports = function (eleventyConfig) { verbose: false }); + eleventyConfig.addFilter("dateString", (dateObj) => { + return new Date(dateObj).toISOString().split("T")[0]; + }); + eleventyConfig.addCollection("posts", async function (collection) { collection = await api.posts .browse({ @@ -52,7 +56,6 @@ module.exports = function (eleventyConfig) { // Bring featured post to the top of the list collection.sort((post, nextPost) => nextPost.featured - post.featured); - console.log(collection); return collection; }); } \ No newline at end of file diff --git a/_includes/layouts/default.njk b/_includes/layouts/default.njk index 90f3ed0..b97945e 100644 --- a/_includes/layouts/default.njk +++ b/_includes/layouts/default.njk @@ -12,6 +12,13 @@
+
+ +
{% block content %} {% endblock content %} diff --git a/_includes/layouts/post.njk b/_includes/layouts/post.njk index c2302dd..58f15ff 100644 --- a/_includes/layouts/post.njk +++ b/_includes/layouts/post.njk @@ -24,14 +24,12 @@ diff --git a/index.njk b/index.njk index f29e197..85af760 100644 --- a/index.njk +++ b/index.njk @@ -7,13 +7,6 @@ pagination: {% extends 'layouts/default.njk' %} {% block content %} {% set postslist = collections.posts %} -
- -
{% for post in postslist %}
@@ -24,7 +17,7 @@ pagination: {{ post.excerpt | safe }}
{% endfor %}