npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@knewbeing/vitepress-plugin-remove-sidebar

v1.1.1

Published

Vite plugin for VitePress that replaces auto-generated sidebar entries with empty placeholders, keeping the sidebar panel visible for custom slot components.

Downloads

443

Readme

@knewbeing/vitepress-plugin-remove-sidebar

npm version license

Vite plugin for VitePress that replaces auto-generated sidebar entries with empty placeholders, keeping the sidebar panel visible for custom slot components.

Copyright (c) 2024-present 知在 ([email protected]). MIT License.

将 VitePress 自动生成的侧边栏条目替换为空占位组,让侧边栏面板保持可见,同时允许自定义 slot 组件完全接管导航内容。


版权声明 / Copyright

本包为 knewbeing(知在,[email protected])的原创作品,独立设计与实现,遵循 MIT 许可证。

Copyright (c) 2024-present knewbeing(知在,[email protected]). All rights reserved. This is an original work created and published independently by knewbeing ([email protected]) under MIT License.


背景 / Background

@knewbeing/vitepress-plugin-autosidebar-tocconfig 阶段会把扫描到的目录树写入 VitePress 的 themeConfig.sidebar

在某些布局方案中,我们希望:

  • VitePress 仍然渲染侧边栏面板(这样 sidebar-nav-after slot 才能挂载自定义的 <SidebarArticleList /> 组件)
  • 不显示任何自动生成的导航项,导航完全由自定义组件接管

若直接把 sidebar 置为空对象或 undefined,VitePress 不会渲染侧边栏面板,slot 也就无法挂载。

本插件的解法:在 autosidebar-toc 写入 sidebar 之后(enforce: 'post'),将每个路径的 sidebar 值替换为 [{ text: '', items: [] }](单个空占位组):

  • VitePress 认为 sidebar 非空,会渲染侧边栏面板
  • 占位组没有任何导航项,配合 CSS display: none 可完全隐藏原始条目
  • sidebar-nav-after slot 正常挂载,自定义组件可正常渲染

安装 / Installation

npm install @knewbeing/vitepress-plugin-remove-sidebar
# or
pnpm add @knewbeing/vitepress-plugin-remove-sidebar

使用 / Usage

.vitepress/config.ts 中注册插件,必须放在 autosidebar-toc 插件之后

// .vitepress/config.ts
import { defineConfig } from 'vitepress'
import { createTocSidebarVitePlugin } from '@knewbeing/vitepress-plugin-autosidebar-toc'
import { createRemoveSidebarPlugin } from '@knewbeing/vitepress-plugin-remove-sidebar'

export default defineConfig({
  vite: {
    plugins: [
      // 1. 先生成 sidebar
      createTocSidebarVitePlugin({ dir: './docs' }),
      // 2. 再清空显示内容(保留面板结构)
      createRemoveSidebarPlugin(),
    ],
  },
})

然后在布局组件中使用 sidebar-nav-after slot 挂载自定义导航:

<!-- .vitepress/theme/MyLayout.vue -->
<template>
  <Layout>
    <template #sidebar-nav-after>
      <SidebarArticleList />
    </template>
  </Layout>
</template>

API

createRemoveSidebarPlugin(): VitePlugin

创建"移除侧边栏显示内容"Vite 插件,无需任何参数。

| 属性 | 值 | |------|-----| | 插件名 | knewbeing:remove-vitepress-sidebar | | enforce | 'post'(在所有 normal/pre 插件之后执行) |

行为说明:

  • 遍历 site.themeConfig.sidebar 的所有 key
  • 将每个 key 的值替换为 [{ text: '', items: [] }]
  • 同时处理所有 i18n locale 下的 themeConfig.sidebar

与其他插件配合 / Works With

| 插件 | 说明 | |------|------| | @knewbeing/vitepress-plugin-autosidebar-toc | 自动生成侧边栏(本插件在其之后执行) |


许可证 / License

MIT

相关链接 / Links