This plugin allows you to easily nest the documents of your application inside of one another. It does so by adding a new parent field onto each of your documents that, when selected, attaches itself to the parent’s tree. When you edit the great-great-grandparent of a document, for instance, all of its descendants are recursively updated. This is an extremely powerful way of achieving hierarchy within a collection, such as parent/child relationship between pages.
Documents also receive a new breadcrumbs field. Once a parent is assigned, these breadcrumbs are populated based on each ancestor up the tree. Breadcrumbs allow you to dynamically generate labels and URLs based on the document’s position in the hierarchy. Even if the slug of a parent document changes, or the entire tree is nested another level deep, changes will cascade down the entire tree and all breadcrumbs will reflect those changes.
With this pattern you can perform whatever side-effects your applications needs on even the most deeply nested documents. For example, you could easily add a custom fullTitle field onto each document and inject the parent’s title onto it, such as “Parent Title > Child Title”. This would allow you to then perform searches and filters based on that field instead of the original title. This is especially useful if you happen to have two documents with identical titles but different parents.
Core features
- Automatically adds a
parentrelationship field to each document - Allows for parent/child relationships between documents within the same collection
- Recursively updates all descendants when a parent is changed
- Automatically populates a
breadcrumbsfield with all ancestors up the tree - Dynamically generate labels and URLs for each breadcrumb
- Supports localization
yarn add @payloadcms/plugin–nested–docs