Generate breadcrumb array between different collections

default discord avatar
mumincelal
3 months ago
4

Hello,



I am using nested-docs plugin to create breadcrumbs. 4 different collection use nested-docs but when I select parent page from one collection to another, the plugin doesn't create breadcrumbs correctly. It doesn't care parent page but I select parent page in same collection then the plugin is successful to create breadcrumbs correctly.



What is the problem here?



Here is my setup:



nestedDocs({ collections: [Page.slug, Post.slug, EnBlog.slug, TrBlog.slug], parentFieldSlug: 'parent', breadcrumbsFieldSlug: 'breadcrumbs', generateLabel: (_, page) => (page.name as string) || '', generateURL: (pages) => pages.reduce((url, page) =>

${url}/${page.slug}

, '') })

If I choose a parent from page collection to page collection, plugin works correct but If I choose a parent from post collection to page collection then plugin can not generate parent page breadcrumbs.

  • default discord avatar
    notchr
    3 months ago

    Hmm good question Mumin, I think @jacobsfletch can help with this one as they most recently updated that repo

  • default discord avatar
    mumincelal
    3 months ago

    @jacobsfletch any idea?

  • discord user avatar
    jacobsfletch
    Payload Team
    3 months ago

    Interesting, the plugin was never designed to work across multiple collections like that. I'm not sure we'd ever be able to create hierarchy in this way without some rethinking how we traverse documents up the tree.

  • default discord avatar
    mumincelal
    3 months ago

    I don't know you have plan to integrate this but I created an issue for that anyway.

    https://github.com/payloadcms/plugin-nested-docs/issues/19
Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.