Search code examples
graphqlgatsby

Is there any way to get gatsby-source-filesystem name in gatsby-plugin-mdx query?


I'm using gatsby-plugin-mdx to create pages. But I want to create different kinds of pages based on the folder they are sourced from with gatsby-source-filesystem. I made the name different in the gatsby-source-filesystem config but I can't seem to pass that along to the mdx node. Does anyone know of a way to do this?


Solution

  • Don't query allMdx directly. Instead do query for allFile using a filter for sourceInstanceName field.

    {
      allFile(filter: { sourceInstanceName: { eq: "products" } }) {
        childMdx { ... }
      } 
    }