payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
25.72k stars 1.64k forks source link

Nested Docs URL conflicts when using same slug with different parents #5879

Open truthseekers opened 7 months ago

truthseekers commented 7 months ago

Link to reproduction

No response

Describe the Bug

I am allowed to use the same slug with different parents, but the front end does not pull the correct page when following your nested-docs examples. Creating these parent-child relationships causes problems:

/service-one/ /service-one/location-one /service-two/ /service-two/location-one

Visiting localhost:3001/service-two/location-one displays the /service-one/location-one page.

To Reproduce

Follow these steps to setup payload: https://github.com/payloadcms/payload/tree/main/examples/nested-docs/payload

Follow these steps to setup next with app router: https://github.com/payloadcms/payload/tree/main/examples/nested-docs/next-app

Create parent and child pages with same slug but different parents to experience problem. Example:

/plumbing/ /plumbing/dallas/ /roofing/ /roofing/dallas

And The app will not pull the correct page when trying to visit /roofing/dallas or /plumbing/dallas

Payload Version

"latest" (says 2.4 in node_modules)

Adapters and Plugins

No response

sarfarazsiddiquii commented 7 months ago

can i work on this issue?

truthseekers commented 7 months ago

can i work on this issue?

If you are talking to me then absolutely. I don't see why the owner would mind either.

DanRibbens commented 7 months ago

I assigned you @sarfarazsiddiquii so we don't duplicate efforts on our end.

Thanks for offerring you help!

sarfarazsiddiquii commented 7 months ago

@DanRibbens , I've submitted a pull request that addresses this issue. I'd appreciate your feedback and any suggestions for improvement. Thanks!