Is this a good approach for creating pages for multiple content typs with GatsbyJS?
There's definitely a lot of duplicate code in those 2 ifs. I'd extract it into function and pass different things as parameters.

Then code would look let's say:

//not sure about name of function and parameters
function nodeFieldPerType(filePath, getNodePath) {
  if (
    node.internal.type === "Mdx" &amp;&amp;
    node.fileAbsolutePath.includes(filePath)
  ) {
    const value = createFilePath({ node, getNode })
    createNodeField({
      name: "slug",
      node,
      value: getNodePath(value),
    })
  }
}


Then you call it like like:

nodeFieldPerType(`content/posts`, value =&gt; `/blog${value}`);
nodeFieldPerType(`content/projects`, value =&gt; `/project${value}`);


This cleans it up a bit. If you keep adding more possible branches, you may need to add more parameters. You can go further to make this as a static configuration and put this into configuration structure, that you fill in advance. Then in your code you just pick the one you need and call it.
Ex: 

config = {
`content/posts`: { getNodePath:  value =&gt; `/blog${value}` }, //object on purpose so that you can add more parameters later
`content/projects`: { getNodePath: value =&gt; `/project${value}` },
}


And then instead of your ifs you check if filePath exists in this config and if it does, you call function with parameters in config.