Sidebar

A docusaurus sidebar file named typedoc-sidebar.cjs is published to the relevant output directory along with the generated markdown documentation.

Referencing in sidebars.js

This file can be referenced in sidebars.js using a sidebar slice and can be configured in following way:

sidebars.js
module.exports = {
  typedocSidebar: [
    {
      type: 'category',
      label: 'Typedoc API',
      link: {
        type: 'doc',
        id: 'api/index',
      },
      items: require('./docs/api/typedoc-sidebar.cjs'),
    },
  ],
};

Injecting into autogenerated sidebar

If your sidebar is autogenerated and it is not possible to reference it in sidebars.js, you can inject the file into the autogenerated sidebar in the presets object in docusaurus.config.js using the sidebarItemsGenerator function:

docusaurus.config.js
 
function injectTypeDocSidebar(items) {
  return items.map((item) => {
    if (item.link?.id === 'api/index') {
      return {
        ...item,
        items: require('./docs/api/typedoc-sidebar.cjs'),
      };
    }
    return item;
  });
}
 
presets: [
    [
      'classic',
      /** @type {import('@docusaurus/preset-classic').Options} */
      ({
        docs: {
          async sidebarItemsGenerator({
            defaultSidebarItemsGenerator,
            ...args
          }) {
            return injectTypeDocSidebar(
              await defaultSidebarItemsGenerator(args),
            );
          },
        },
      }),
    ],
  ],