Skip to content

Add breadcrumbs to docs #6096

Closed
Closed

Description

@Josh-Cena

Have you read the Contributing Guidelines on issues?

Description

Docs should have breadcrumbs in addition to sidebar.

Has this been requested on Canny?

No

Motivation

I've just built this feature for someone: PatelN123/Digital-Support-Notes#1 (That person just wanted the primary category, but I did extract the entire breadcrumb list)

It wasn't quite ergonomic, and I think it would make sense to make itself into the core.

API design

It would be opt-in, something like showBreadcrumbs in the docs plugin. I think we can also set a metadata to help with SEO?

If we don't want an opinionated implementation for the UI component, we can just implement a useBreadCrumbs in theme-common and let users wrap DocItem to implement what they want.

Have you tried building it?

Yes, see that PR for how I did it.

Self-service

  • I'd be willing to contribute this feature to Docusaurus myself.

Activity

  1. added
    feature
    on Dec 11, 2021
  2. slorber commented on Dec 15, 2021

    @slorber
    Collaborator

    Yes, we could add that option, and probably turn it on by default if it looks good. I'm fine with an opinionated design as long as it can be turned off

    SEO metas should probably always be there even if the option is turned off?

    useBreadcrumb in theme-common 👍 the lighter the UI component the better

    There's already a component in Infima:

    https://infima.dev/docs/components/breadcrumbs

    Seems only used on the search page 😅 : https://docusaurus.io/search?q=doc

    image

  3. christopherklint97 commented on Dec 16, 2021

    @christopherklint97
    Contributor

    Is it ok if I start working on this? Or will the implementation just be @Josh-Cena useBreadcrumbs?

  4. Josh-Cena commented on Dec 16, 2021

    @Josh-Cena
    CollaboratorAuthor

    @christopherklint97 You can start with useBreadcrumbs + a metadata in each Doc item, and then we can discuss if the UI feature is useful

  5. slorber commented on Dec 17, 2021

    @slorber
    Collaborator
    • a metadata in each Doc item

    It is probably unnecessary to provide additional metadata here.

    We now have a theme-common useDocsSidebar() (in docsUtils.ts), it should be possible to build on top of it a useDocsBreadcrumb(docId).

    I'd like to use more context/hooks in the future instead of manipulation props, considering the doc metadata/sidebar should be available in React context wherever those hooks will be called (ie in Doc page components, including custom made components).

  6. Josh-Cena commented on Dec 17, 2021

    @Josh-Cena
    CollaboratorAuthor

    When I say metadata I don't mean props. I mean hooks + <head><meta />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions