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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@zyjared/vitepress-sidebar

v0.4.2

Published

读取源目录,根据文件位置与 frontmatter 生成侧边栏数据。

Readme

vitepress-sidebar

读取源目录,根据文件位置与 frontmatter 生成侧边栏数据。

使用

pnpm add -D @zyjared/vitepress-sidebar
// .vitepress 的 config.ts
import { defineSidebarAuto } from '@zyjared/vitepress-sidebar'
import { defineConfig } from 'vitepress'

export default defineConfig({
  // ...
  srcDir: 'docs',
  themeConfig: {
    sidebar: defineSidebarAuto({ srcDir: 'docs' })
  }
})

为了与 config 中的 srcDir 保持一致,可以使用 defineConfigWithSidebar()

// .vitepress 的 config.ts
import { defineConfigWithSidebar } from '@zyjared/vitepress-sidebar'

export default defineConfigWithSidebar({
  // ...
  srcDir: 'docs'
})

内部的 sidebar 会被替换,暂不处理

frontmatter

---
order: 1          # 作为排序依据,优先级最高
date: 2025-01-01  # 作为排序依据
                  # 链接名也是排序依据,优先级最低

title: 标题
sidebar: false    # 不显示在侧边栏
---

# 一级标题

这些都会是链接名

1. frontmatter.title (优先级最高)
2. 一级标题
3. 文件名

多级侧边栏与index

默认情况下,一个文件夹内如果不存在 index.md 时,该文件夹是一个分组。并且,该分组会出现在侧边栏,而分组名就是文件夹名。

如果一个文件夹下存在 index.md,也可以通过 frontmatter 设置侧边栏规则。

<!-- index.md -->
---
sidebar: group      # 表示所在文件夹应当视为分组
sidebar: collapsed  # 表示所在文件夹应当视为分组,并且默认收起

sidebar: true       # 不是分组,但是 `index` 应当视为链接出现在侧边栏

sidebar: false      # 所在文件夹下的文档都不应当出现在侧边栏
---

不设置 sidebar 时,表示不是分组,`index` 链接也不会出现在侧边栏。