Gatsby JS markdown posts sorting by new?

I tried using Gatsby to build a blog for myself, and the markdown posts I added in are not sorted by the date I keyed in in the front matter.

How am I supposed to make all the posts sorted by time??

Here is the project repo: https://github.com/zhouxiang19910319/gatsby_tr

1 Like

Solved this issue:

export const pageQuery = graphql`
  query BlogIndexQuery{
      allMarkdownRemark
      (sort: { fields: [frontmatter___date], order: DESC })
      {
        edges{
          node{
            id
            frontmatter{
              path
              title
              date
              author
            }
          }
        }
      }
    }
`
export default blogPage
1 Like