Browse Source

fix: chromium sorting of posts

restructure
Garrit Franke 4 years ago
parent
commit
aae003bf20
  1. 4
      components/BlogList.js

4
components/BlogList.js

@ -16,7 +16,9 @@ const BlogList = ({ posts }) => {
<ul className="list">
{posts.length > 1 &&
posts
.sort((a, b) => a.frontmatter.date < b.frontmatter.date)
// Ternary operator is used to fix chromium sorting
// See: https://stackoverflow.com/a/36507611
.sort((a, b) => (a.frontmatter.date < b.frontmatter.date ? 1 : -1))
.map((post) => (
<Link key={post.slug} href={{ pathname: `/posts/${post.slug}` }}>
<a>

Loading…
Cancel
Save