Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Nested Docs: Handling Slug Conflicts and Query Limitations

default discord avatar
livoglast year
1

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:

pages

and

recipes

. The

pages

collection resembles what we would typically see in WordPress. I've implemented nested docs on

pages

but I'm unsure about how to lock down the slugs so that

pages

can't create URLs that conflict with the

recipes

collection. For example, how can I prevent

pages

from creating any URLs with

/recipes

in 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

path

field that saves the last index of the breadcrumbs array, and populating it using a

beforeValidate

hook. Is this the right approach? Is there a way to ensure that this

path

doesn'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! 🙏

  • default discord avatar
    zephury.last year

    Did you ever figure out how you're going to handle these things? Going through some of the same thoughts myself right now.

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.