jooy2 / vitepress-sidebar

🔌 VitePress Sidebar is a plugin for VitePress that automatically configures and manages the sidebar of your page with simple settings.
https://vitepress-sidebar.cdget.com
MIT License
144 stars 7 forks source link

I don't understand how to do the Multiple Sidebars #148

Closed MikeCZ23 closed 3 weeks ago

MikeCZ23 commented 4 months ago

I don't understand how to do the Multiple Sidebars

jooy2 commented 4 months ago

Hello! Thank you for using vitepress-sidebar plugin!

You can configure multiple sidebar environments using the help links below: https://vitepress-sidebar.jooy2.com/multiple-sidebars-how-to

If you're having trouble, please leave a reply with the specifics of your issue.

Regards,

MikeCZ23 commented 4 months ago

Hello! Thank you for using vitepress-sidebar plugin!

You can configure multiple sidebar environments using the help links below: https://vitepress-sidebar.jooy2.com/multiple-sidebars-how-to

If you're having trouble, please leave a reply with the specifics of your issue.

Regards,

It's just that I don't understand the instructions. I don't know exactly how to do it. I need see full file structure. .Vitepress/config.mts right?

jooy2 commented 4 months ago

I apologize for the delay in responding.

Yes, you need to declare generateSidebar in the value of themeConfig.sidebar in the config file (extension can be js, ts, mts) in the .vitepress folder: https://vitepress-sidebar.jooy2.com/getting-started

The purpose of multiple sidebar is to display different sidebar menus on a specific routing path.

The vitepress-sidebar scans the specified directory and generates the menus. Normally, you will see the same menu on any article page.

First, documentRootPath can be specified as the parent folder of the folder where the .vitepress directory is located. See below:

/
├─ package.json
├─ src/
├─ docs/        <--------------- `documentRootPath` ('/docs')
│  ├─ .vitepress/        <------ VitePress config directory
│  ├─ a-docs/
│  ├─ b-docs/
│  ├─ hello.md
│  └─ index.md
└─ ...

If you have a /a path (e.g. https://vitepress.dev/a) and a /b path (e.g. https://vitepress.dev/b), and you want to display different menus on the two paths, specify the resolvePath option with /a/ and /b/ respectively.

The scanStartPath option can specify which part of the directory to display the documents in when that path is reached. For example, if you only want to display documents in the /a path and only the /a-docs folder, and if you only want to display documents in the /b path and only the /b-docs folder, then scanStartPath would be a-docs, b-docs, respectively.

The remaining options can be set separately for each path per this article(https://vitepress-sidebar.jooy2.com/api). As a result, the result of combining the examples above is:

generateSidebar([
  {
    documentRootPath: 'docs',
    scanStartPath: 'a-docs',
    resolvePath: '/a/',
    useTitleFromFileHeading: true,
  },
  {
    documentRootPath: 'docs',
    scanStartPath: 'b-docs',
    resolvePath: '/b/',
    useTitleFromFrontmatter: true,
  }
]);

Let me know if you run into any issues, Regards,

MikeCZ23 commented 4 months ago

it'll only take me one path, not two.

sidebar: generateSidebar([
      {
        documentRootPath: '/',
        scanStartPath: 'docs',
        resolvePath: '/docs/',
        useTitleFromFileHeading: true,
        collapsed: true,
      },
      {
        documentRootPath: '/',
        scanStartPath: 'news',
        resolvePath: '/news/',
        useTitleFromFrontmatter: true,
        collapsed: true,
      }
    ]),
/
├─ package.json
├─ .vitepress/  
├─ news/
├─ docs/
├─ index.md
└─ ...
DanielTrommel commented 1 month ago

@MikeCZ23 : did you already manage to get it to work?

@jooy2 tried many things, but the resolvePath option does not seem to be working for me:

This is my setup:

/
├─ package.json
├─ docs/        <--------------- `documentRootPath` ('/docs')
│  ├─ .vitepress/        <------ VitePress config directory
│  ├─ 1-getting-started/
│  ├─ 2-documentation/
│  └─ index.md
└─ ...

I am using this in my config:

sidebar: generateSidebar( 
  {
    documentRootPath: 'docs',
    scanStartPath: '1-getting-started',
    resolvePath: '/1-getting-started/',
  },
  {
    documentRootPath: 'docs',
    scanStartPath: '2-documentation',
    resolvePath: '/2-documentation/',
  },
),

My problem is that the URL does not include the resolvePath (/1-getting-started/ or /2-documentation/). I am assuming that was the idea of that setting?

Using 1.24.0.

NatureK88 commented 4 weeks ago

@MikeCZ23 : did you already manage to get it to work?

@jooy2 tried many things, but the resolvePath option does not seem to be working for me:

This is my setup:

/
├─ package.json
├─ docs/        <--------------- `documentRootPath` ('/docs')
│  ├─ .vitepress/        <------ VitePress config directory
│  ├─ 1-getting-started/
│  ├─ 2-documentation/
│  └─ index.md
└─ ...

I am using this in my config:

sidebar: generateSidebar( 
  {
    documentRootPath: 'docs',
    scanStartPath: '1-getting-started',
    resolvePath: '/1-getting-started/',
  },
  {
    documentRootPath: 'docs',
    scanStartPath: '2-documentation',
    resolvePath: '/2-documentation/',
  },
),

My problem is that the URL does not include the resolvePath (/1-getting-started/ or /2-documentation/). I am assuming that was the idea of that setting?

Using 1.24.0.

I have the some problem, resolvePath seems don't work. Using the latest vitepress and plugin.

DanielTrommel commented 4 weeks ago

Meanwhile I found why it didn't work for me:

I called generateSidebar() with as input an array, but I made a mistake: see my post above with the code. The input is {..},{..} bit this is not a valid array. It should be [{..},{..}] of course, with the square brackets.

So: generateSidebar([{..},{..}])

I didn't notice my mistake at first, and apparently Viscose with a mixed Vue/TS code didn't report this either...

Hope this helps others!

On Sat, Aug 10, 2024, 12:14 NatureK @.***> wrote:

@MikeCZ23 https://github.com/MikeCZ23 : did you already manage to get it to work?

@jooy2 https://github.com/jooy2 tried many things, but the resolvePath option does not seem to be working for me:

This is my setup:

/ ├─ package.json ├─ docs/ <--------------- documentRootPath ('/docs') │ ├─ .vitepress/ <------ VitePress config directory │ ├─ 1-getting-started/ │ ├─ 2-documentation/ │ └─ index.md └─ ...

I am using this in my config:

sidebar: generateSidebar( { documentRootPath: 'docs', scanStartPath: '1-getting-started', resolvePath: '/1-getting-started/', }, { documentRootPath: 'docs', scanStartPath: '2-documentation', resolvePath: '/2-documentation/', }, ),

My problem is that the URL does not include the resolvePath ( /1-getting-started/ or /2-documentation/). I am assuming that was the idea of that setting?

Using 1.24.0.

I have the some problem, resolvePath seems don't work.

— Reply to this email directly, view it on GitHub https://github.com/jooy2/vitepress-sidebar/issues/148#issuecomment-2280813428, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEYV7OBK4CIUEPFKTDTESADZQXRWXAVCNFSM6AAAAABGTKEMT6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOBQHAYTGNBSHA . You are receiving this because you commented.Message ID: @.***>

jooy2 commented 3 weeks ago

Hello guys!

I recently improved the documentation to make it clearer to use multiple sidebars in vitepress-sidebar. You can check it out here: https://vitepress-sidebar.jooy2.com/advanced-usage/multiple-sidebars-how-to

Please note that the menu may not display correctly if you pass incorrect arguments when configuring the option, or if the nested paths and URIs are different.

In addition, issues with the rewrite configuration of VitePress or your website could cause issues in other cases, so be aware of that.

Since some of the cases in this issue are not currently reproducible or have been resolved, and since the original purpose of this issue was about usage, i'm closing this issue.

If you encounter any new issues, please open a new issue.

Thank you.

DanielTrommel commented 3 weeks ago

Very good improvement 👍 thanks for the effort.

On Tue, Aug 13, 2024, 03:22 Jooy @.***> wrote:

Hello guys!

I recently improved the documentation to make it clearer to use multiple sidebars in vitepress-sidebar. You can check it out here: https://vitepress-sidebar.jooy2.com/advanced-usage/multiple-sidebars-how-to

Please note that the menu may not display correctly if you pass incorrect arguments when configuring the option, or if the nested paths and URIs are different.

In addition, issues with the rewrite configuration of VitePress or your website could cause issues in other cases, so be aware of that.

Since some of the cases in this issue are not currently reproducible or have been resolved, and since the original purpose of this issue was about usage, i'm closing this issue.

If you encounter any new issues, please open a new issue.

Thank you.

— Reply to this email directly, view it on GitHub https://github.com/jooy2/vitepress-sidebar/issues/148#issuecomment-2285167167, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEYV7OD5H4HYIPWC6USC7LLZRFNUZAVCNFSM6AAAAABGTKEMT6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOBVGE3DOMJWG4 . You are receiving this because you commented.Message ID: @.***>