Skip to content

Sidebar categories linking to a doc or category index page #2643

Closed

Description

@XavierNV

🚀 Feature

Category in docs are only container for subitems (topics). But some help system enable category to be introductory topic to subitems (ie containing text that introduce the subitems or refers to subitems ie see also links to subtopic1, sub..)

Have you read the Contributing Guidelines on issues?

Yes

Motivation

Interested to use the Docusaurus Help System but before investing in it wan't to know the roadmap

Pitch

It's pretty useful. If you can read the introductory topic, you sometimes don't have to click/navigate to subtopics. It'a a better system than having a first topic (~overview) refering to following topics in a same level appearance > introductory topic has to be a level upper the subtopics..
Example of documentation with introductory topics :
https://www.gatsbyjs.org/docs/deploying-and-hosting/
https://www.innovasys.com/help/hs2019.1/authoringcontent.html
https://markdownmonster.west-wind.com/docs/

Hope my explaination is not too hard to understand..
Thanks to the docusaurus team for their work

Regards, Xavier

Activity

  1. added
    feature
    status: needs triage
    on Apr 22, 2020
  2. changed the title [-]Enable docs "category" to be introductory topic for subtopics[/-] [+]Allow docs "category" to be introductory topic for subtopics[/+] on Apr 25, 2020
  3. hsiaoer commented on May 22, 2020

    @hsiaoer

    +1 to this feature request. I have a case right now where I'm migrating docs over to docusaurus and we've set all nav items to be expanded by default.

    themeConfig: {
        sidebarCollapsible: false,
    }
    

    Currently if you try clicking on the category item in the nav, nothing happens and it would be helpful to be able to add an optional link to a doc page on the category:

    Example where introDoc.md is the doc when you click on the nav item.

    {
            type: "category",
            label: "Introduction",
            rootItem: introDoc,
            items: [subdoc1, subdoc2]
    }
    
  4. removed
    status: needs triage
    on Jun 5, 2020
  5. yangshun commented on Jun 5, 2020

    @yangshun
    Contributor

    Some users want this behavior but some other users prefer that the category are just labels and not clickable. If we were to add support for this, we might need to change how the pure categories look, such that they don't look clickable.

  6. sladyn98 commented on Jul 15, 2020

    @sladyn98

    @yangshun Is this still a starter issue to be worked on if yes I could maybe give it a shot.

  7. slorber commented on Jul 20, 2020

    @slorber
    Collaborator

    Hey, didn't notice this issue, that also seems related to a more recent one: #3051

    @sladyn98 there's ongoing work to be merged on the docs plugin + a few other important refactors I'd like to do.
    This won't be time lost to have such a POC of this feature, and would help collect feedback, but just be aware that you might not be able to rebase it easily, and might need to re-open a brand new pull request 🤪

  8. slorber commented on Jul 20, 2020

    @slorber
    Collaborator

    Raw thoughts but here's a possible api:

    {
            type: "categoryDoc",
            label: "Introduction",
            id: "introDocId",
            items: [subdoc1, subdoc2]
    }
    

    Would render the introDocId doc.

    {
            type: "categoryDoc",
            label: "Introduction",
            id: undefined, // on purpose
            items: [subdoc1, subdoc2]
    }
    

    Would render an automatically generated table of content of all the inner-tree of this category (we could later see how to make this view more useful by adding additional data to it, maybe a small doc summary or something)

  9. changed the title [-]Allow docs "category" to be introductory topic for subtopics[/-] [+]Sidebar categories linking to a doc or category index page[/+] on Nov 5, 2020
  10. TomPeirs commented on Nov 10, 2020

    @TomPeirs

    Is there any update on this feature?
    Is there any proposed solution for now?
    Currently I have a duplicate entry in my sidebar representing the category file. This of course looks a little bit ugly.

  11. slorber commented on Nov 10, 2020

    @slorber
    Collaborator

    This is quite often requested (#3686) so we'll try to find a solution, but it will come after i18n support.

    In the meantime, if someone wants to design the API surface and write an exhaustive RFC, so that it is flexible and suit all the use-cases reported, that would help.

    The design of this feature is not so straightforward as we are not sure yet how it should behave regarding category collapsing.

  12. chrisdostert commented on Nov 10, 2020

    @chrisdostert

    Just wanted to add that this is how the kubernetes.io docs work which to me are great. Would love to have this be available (if not default) behavior in docusaurus!

  13. ctlajoie commented on Nov 21, 2020

    @ctlajoie

    I would definitely like to see this as well. I have encountered the requested functionality several times just today on different sites. In addition to the kubernetes.io docs mentioned by @chrisdostert:

    I like the sidebar behavior of the GitHub docs best (although the k8s docs operate similarly). It hides the sub-articles of the other categories that are not related to doc currently in view. I do not find this behavior confusing or annoying. It makes the sidebar easier to grok.

  14. slorber commented on Nov 23, 2020

    @slorber
    Collaborator

    Thanks for showing some examples. We'll try to find an API that allows all these slightly different UX so that you can choose the one you want.

    I like the sidebar behavior of the GitHub docs best (although the k8s docs operate similarly). It hides the sub-articles of the other categories that are not related to doc currently in view. I do not find this behavior confusing or annoying. It makes the sidebar easier to grok.

    At the same time it's confusing if the item you click on immediately change position. I guess it's an acceptable tradeoff, but we should probably not enforce this specific UX.

  15. 42 remaining items

  16. slorber commented on Nov 26, 2021

    @slorber
    Collaborator

    Yes, we'll allow collapsing a category

    External links have a different icon, this can be seen here: https://deploy-preview-5830--docusaurus-2.netlify.app/tests/docs/category/tests/

    If possible, it would be nice if you could also fetch the card data only somehow, where I could have an index page, but then still render cards on it as well.

    I don't understand what this means sorry 😅

    Perhaps we could add a little bit more spacing between the Title and the Icon of a card?
    Would there be a possibility to add a customization option to assign those icons/svgs for the card icons?

    We'll likely improve the design and add customization options later. Here I'm mostly focusing on the initial MVP with the UX and a good extensible public API that we can improve later.

    Note that these theme components are well encapsulated and easy to customize with a swizzle.


    Thanks for your feedback, which is mostly about design and "shortcut" options, we can improve all that incrementally from the current state later in subsequent PRs, and in the meantime using swizzle is likely a good enough workaround until we figure out the most wanted customization apis.

  17. Josh-Cena commented on Nov 26, 2021

    @Josh-Cena
    Collaborator

    If possible, it would be nice if you could also fetch the card data only somehow, where I could have an index page, but then still render cards on it as well.

    @slorber By that he means, you have a normal doc page as index page, but inject the category items in it as JSON so it can be rendered somewhere in the middle of the page, kind of like the TOCInline where we have a global toc export to do this.

    My idea would be to inject this in MDXProvider

  18. slorber commented on Nov 26, 2021

    @slorber
    Collaborator

    Oh I see, something like this?

    image

    It's already technically possible atm using hooks in the MDX doc, but probably not with the most intuitive API. We can figure out later how to add MDX shortcodes for that.

    ## Category Content
    
    import DocCardList from '@theme/DocCardList';
    import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
    
    <DocCardList items={useCurrentSidebarCategory().items}/>
  19. dsmmcken commented on Dec 2, 2021

    @dsmmcken
    Contributor

    Is it easy to change/remove the icons, or would I have to swizzle the component for that?

  20. Josh-Cena commented on Dec 2, 2021

    @Josh-Cena
    Collaborator

    Is it easy to change/remove the icons, or would I have to swizzle the component for that?

    @slorber Is it possible to popularize the idea of CSS ::before pseudoelements for these icons?

  21. seanbrakefield commented on Dec 2, 2021

    @seanbrakefield

    I’ve been following the progress of this for a while now, and I love how this is forming. Really great work!

    Request:
    Can you close the Table of Contents panel when tapping the Category item (that has a page) on the mobile version? Currently, that panel stays open which makes it seem like nothing has occurred.

  22. slorber commented on Dec 3, 2021

    @slorber
    Collaborator

    Is it easy to change/remove the icons, or would I have to swizzle the component for that?

    @slorber Is it possible to popularize the idea of CSS ::before pseudoelements for these icons?

    For now you can swizzle the DocCard component

    We don't have yet a good way to manage theme icons, we'll try to normalize how we handle icons in themes as part of #5865 and make sure that overriding an icon is consistent for all the existing use-cases of the theme.

    If you have a better icon/design we can also improve our current design. Feel free to override DocCard in userland for now, show us the result, and eventually if the design is better we can make it the default later.


    Can you close the Table of Contents panel when tapping the Category item (that has a page) on the mobile version? Currently, that panel stays open which makes it seem like nothing has occurred.

    Yes, also noticed that ;) this has been fixed

  23. slorber commented on Dec 3, 2021

    @slorber
    Collaborator

    This has been published in canary (0.0.0-4241) and scheduled for a release next week

    Please give it a try and tell us if it works fine ;)

  24. added a commit that references this issue on Feb 17, 2022
  25. sivert-io commented on Jul 11, 2022

    @sivert-io

    Hey guys 😄
    I've been struggling to find the option to enable this?
    I didn't want to bother reading through all these comments, therefore I am asking :)

    I also couldn't find anything related to it in your docs

  26. Josh-Cena commented on Jul 11, 2022

    @Josh-Cena
    Collaborator
  27. bfelbo commented on Mar 27, 2023

    @bfelbo

    If you can read the introductory topic, you sometimes don't have to click/navigate to subtopics. It'a a better system than having a first topic (~overview) refering to following topics in a same level appearance > introductory topic has to be a level upper the subtopics.. Example of documentation with introductory topics : https://www.gatsbyjs.org/docs/deploying-and-hosting/

    Interestingly, Gatsby actually moved away from this style. My guess would be that it's because readers might miss that they can click on the category sidebar to read info. Readers might sometimes expand the category using the arrow instead, thereby missing crucial introductory info. This can also happen if the reader opens a category subpage from an external link, in which case it's unlikely they'll know to click the category in the sidebar since it's already expanded.

    I'd argue that one can achieve the best of both worlds by making any clicks to the category redirect the reader to the intro subpage. That way, it's still a quick experience (same # of clicks), but makes the intro information explicit. I've created #8833 to add support for this :)

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