Skip to content

How do I add title sections within the sidebar? #2704

Answered by mutasim77
StephenTangCook asked this question in Q&A
Discussion options

You must be logged in to vote

If we look at the source code in the pages/docs/_meta.json directory, we can see something like this:

{
  "index": "Introduction",
  "guide": "",
  "-- Themes": {
    "type": "separator",
    "title": "Themes"
....
},

You may wonder how this works. Look, we are passing a type of separator. Now, in your theme.config.ts file, we can add something like this to ur configurations:

const config: DocsThemeConfig = {
  ...,
  sidebar: {
    titleComponent({ title, type }) {
      if (type === 'separator') {
        return <span className="cursor-default">{title}</span>;
      }
      return <>{title}</>;
    },
    defaultMenuCollapseLevel: 1,
    toggleButton: true
  },
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by StephenTangCook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants