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
157 stars 7 forks source link

Feature Request: Honor/inherit `scrExclude` from VitePress #181

Open Peque opened 2 weeks ago

Peque commented 2 weeks ago

Right now, excludePattern allows you to define file/directory exclusions based on patterns, just like srcExclude does.

It does work fine but, apparently, it requires you to declare both srcExclude and excludePattern (with the same values).

It would be great if VitePress Sidebar could honor srcExclude. That means it would inherit all srcExclude values, which probably makes sense since the srcExclude is declared at a "higher" level than the Sidebar plugin (it affects the whole VitePress project).

jooy2 commented 2 weeks ago

Hello, thank you for using vitepress-sidebar and leaving your feedback.

First, based on the current behavior, this plugin does not directly read VitePress' config because it is declared at the themeConfig -> sidebar level, not at the plugin level in Vite. Therefore, we need to find a way to read the settings in the config file to make this work.

For now, if you want to pass the same value with srcExclude, there is a way to define it as a global constant and use it on both sides.

const srcExclude = ['**/README.md', '**/TODO.md'];

export default defineConfig({
  title: 'VitePress Sidebar',
  srcExclude: srcExclude,
  themeConfig: {
    sidebar: generateSidebar({       
        documentRootPath: '/docs',
        excludePattern: srcExclude,
      };
    }),
  }
});

It doesn't seem likely that this issue will be addressed quickly, but we'll keep it open for future reference for others.

Regards,