From 11e571dc17293f2116d3cb8b42f3b46f959b57a0 Mon Sep 17 00:00:00 2001 From: benjaminramey Date: Mon, 5 Oct 2020 21:48:04 -0500 Subject: [PATCH] Format dates and sort archive posts descending by date --- src/pages/archive.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pages/archive.js b/src/pages/archive.js index 9a3b58c..00c71b3 100644 --- a/src/pages/archive.js +++ b/src/pages/archive.js @@ -11,10 +11,13 @@ export default function Archive({ data }) { }); const yearGroupsHtml = yearGroups.map(yg => { + yg.edges.sort(function(a,b) { + return new Date(b.node.frontmatter.date) - new Date(a.node.frontmatter.date); + }); const postListItems = yg.edges.map(({node}) => { return (
  • - {node.frontmatter.date} - {node.frontmatter.title} + {node.frontmatter.shortDate} - {node.frontmatter.title}
  • ); }); @@ -48,7 +51,8 @@ export const query = graphql` } frontmatter { title - date(formatString: "MMM Do") + date + shortDate: date(formatString: "MM/DD") } } }