React Next.js and nested slugs

Hi,

Hoping this is the right place to ask!

I’m building my site structure in DatoCMS and React like this:

projects/project-category/project-detail

And this is my query:

allProjects {
    slug
    projectCategoryParent {
      slug
    }
    genericPageParent {
      slug
    }
}

…can someone please point me in the right direction showing how to use getStaticPaths and getStaticProps in such a way that Project pages can be reached by joining all of the slugs together?

Thank you!