Hey everyone 👋,
I've been using the nested docs plugin with Payload CMS and it's left me with some questions about data structure. I have two main collections:
pagesand
recipes. The
pagescollection resembles what we would typically see in WordPress. I've implemented nested docs on
pagesbut I'm unsure about how to lock down the slugs so that
pagescan't create URLs that conflict with the
recipescollection. For example, how can I prevent
pagesfrom creating any URLs with
/recipesin the breadcrumbs?
On a related note, I've run into an issue when querying pages based on their breadcrumbs. I've tried querying like this:
/api/pages?where[breadcrumbs.url][equals]=%2Frecipes%2Fwith%2Fsugar, but it doesn't solve the issue when multiple pages match parts of the query. I've considered adding a hidden
pathfield that saves the last index of the breadcrumbs array, and populating it using a
beforeValidatehook. Is this the right approach? Is there a way to ensure that this
pathdoesn't collide with another collection's path before saving?
I've searched through the Discord and documentation, but I haven't found anything that addresses these issues. I’m relatively new to Payload but have a lot of experience with JavaScript. This specific issue is a bit of a snag for me, and I could really use some advice. We're anticipating our collection entities to reach around 30,000, and we want to prevent unexpected pages from being rendered.
Thanks in advance for your help! 🙏
Did you ever figure out how you're going to handle these things? Going through some of the same thoughts myself right now.
Star
Discord
online
Get dedicated engineering support directly from the Payload team.