docusaurus-openapi icon indicating copy to clipboard operation
docusaurus-openapi copied to clipboard

Support for custom items inside existing navigation sidebar

Open searchableguy opened this issue 2 years ago • 8 comments

Can you have existing navigation items on the API page?

I looked through the existing issues and I found some talk about nesting support for multiple API files but nothing about using it with existing navigation items.

Is it possible to add custom sidebar generator?

I will be happy to contribute if it's not too difficult to allow.

searchableguy avatar Sep 27 '22 21:09 searchableguy

We don’t plan on adding a double sidebar like this. We support multiple api files and nesting through collapsing sections in a single sidebar. If you want a double sidebar I would recommend using redocusaurus. Is there a reason you were looking to use this plugin instead?

bourdakos1 avatar Sep 29 '22 17:09 bourdakos1

I apologise for not being clear. I'm not asking for double sidebar and embedding generated open API pages inside existing docs.

I want to add custom items to the sidebar aside from the generated API category.

docusaurus for example allow you to customize sidebar with generated elements using sidebar.js

const sidebar = [
    {
      label: "API",
      type: "category",
      items: [
        {
          type: "autogenerated",
          dirName: "openapi", // open API generated sidebar items.
        },
        { 
          type: "link",  // custom ones user want to display.
          href: "example.com"
        }
      ],
    },
   }
 ]

searchableguy avatar Sep 29 '22 18:09 searchableguy

Ooh I see, yes we support that. It’s not well documented at the moment, but I can provide some more information on how to do that shortly

bourdakos1 avatar Sep 29 '22 18:09 bourdakos1

Thank you so much. I couldn't find anything about it in the examples and issue so I assumed it wasn't available.

searchableguy avatar Sep 29 '22 18:09 searchableguy

Take a look at this PR #193 for some info on how to structure things to customize the sidebar. There's also an example in the demo with custom md pages added

bourdakos1 avatar Sep 29 '22 22:09 bourdakos1

Oh sorry looks like we haven't released a new version since that PR. If you want, you can follow the doc here: https://github.com/cloud-annotations/docusaurus-openapi/tree/main/scripts

and make a PR similar to this one: https://github.com/cloud-annotations/docusaurus-openapi/pull/192

Then I will approve & merge which will automatically release a new version of the plugin

bourdakos1 avatar Sep 29 '22 22:09 bourdakos1

@bourdakos1 I checked the example.

I might be missing it but it does not show to use a custom sidebar.js for the API page. Could you clarify this for me?

I only see support for using markdown pages and have them appear which is great but if someone wants to use their existing sidebar.js, I don't see an option in the example especially relevant if you want to add links.

searchableguy avatar Oct 05 '22 10:10 searchableguy

Ah I see, we don’t have a way to add links. Happy to accept a PR that adds the feature though

bourdakos1 avatar Oct 05 '22 13:10 bourdakos1