Format dates and sort archive posts descending by date
This commit is contained in:
@@ -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 (
|
||||
<li>
|
||||
<a href={node.fields.slug}>{node.frontmatter.date} - {node.frontmatter.title}</a>
|
||||
<a href={node.fields.slug}>{node.frontmatter.shortDate} - {node.frontmatter.title}</a>
|
||||
</li>
|
||||
);
|
||||
});
|
||||
@@ -48,7 +51,8 @@ export const query = graphql`
|
||||
}
|
||||
frontmatter {
|
||||
title
|
||||
date(formatString: "MMM Do")
|
||||
date
|
||||
shortDate: date(formatString: "MM/DD")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user