Posts Cross-Appearing in the Wrong Directories – Gatsby

I am building a blog with 2 different blog subdirectories. One is /blog/{blog_slug}/ and the other is /projects/{blog_slug}. My folder structure is as follows:

blog/
    blog1/
         index.mdx
         hero.jpg
    blog2/
          index.mdx
          hero.jpg
projects/
        project1/
         index.mdx
         hero.jpg
        project2/
          index.mdx
          hero.jpg
.
.
.

src/pages/
         blog/
             index.js
             {mdx.frontmatter___slug}.js
         projects/
                 index.js
                 {mdx.frontmatter___slug}.js

and my directories look like:

localhost:8000/blog/blog1
localhost:8000/projects/blog1
localhost:8000/blog/blog2
localhost:8000/projects/blog2
localhost:8000/blog/project1
localhost:8000/projects/project1
localhost:8000/blog/project2
localhost:8000/projects/project2

Of course the /blog/ subdirectory shouldn’t contain the project1 post but it does and it will throw a 404 error when you go to it because I have filtered the GraphQL query.
What should I do?
I guess the naming of the {mdx.frontmatter___slug}.js has something to do with it.

I have considered trying to change the “slug” frontmatter of one type of post to something like “project_slug” and then change the js file into {mdx.frontmatter___project_slug}.js but idk if it works and I have it as my last resort.