score:2

Accepted answer

This is when you want to use mapping, but it's not well documented for anything that isn't a Markdown or JSON file.

gatsby-config.js - mapping

// NOTE: the frontmatter `file` and property `base` must have unique values
// That is, don't allow any files to have the same name if mapping `base`
mapping: {
    'MarkdownRemark.frontmatter.file' : 'File.base',
}

So now you can successfully do:

query SiteQuery{
    publications: allMarkdownRemark(
        filter: { fileAbsolutePath: {regex : "/publications/"} }
        sort: { order: DESC, fields: [frontmatter___date] }
    ){
       edges {
           node {
               frontmatter {
                   date(formatString: "MMMM DD, YYYY")
                   title
                   file {
                       publicURL                   
                   }
               }
           }
       }
    }
}

Related Query

More Query from same tag