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

vitepress-plugin-code-tree

v0.12.2

Published

Render code tree structure in your VitePress site.

Downloads

380

Readme

vitepress-plugin-code-tree

Render code tree structure in your VitePress site.

在 VitePress 中渲染代码树结构。

Usage

With Vitepress-tuck

Installation:

# npm
npm install -D vitepress-tuck vitepress-plugin-code-tree
# pnpm
pnpm add -D vitepress-tuck vitepress-plugin-code-tree
# yarn
yarn add -D vitepress-tuck vitepress-plugin-code-tree

Configuration:

// .vitepress/config.ts
import codeTree from 'vitepress-plugin-code-tree'
import { defineConfig } from 'vitepress-tuck'

export default defineConfig({
  plugins: [codeTree()],
})
// .vitepress/theme/index.ts
import type { Theme } from 'vitepress'
import enhanceApp from 'virtual:enhance-app'
import DefaultTheme from 'vitepress/theme'

export default {
  extends: DefaultTheme,
  enhanceApp(ctx) {
    enhanceApp(ctx)
  },
} satisfies Theme

With Vitepress

Installation:

# npm
npm install -D vitepress-plugin-code-tree
# pnpm
pnpm add -D vitepress-plugin-code-tree
# yarn
yarn add -D vitepress-plugin-code-tree

Configuration:

// .vitepress/config.ts
import { defineConfig } from 'vitepress'
import { codeTreeMarkdownPlugin } from 'vitepress-plugin-code-tree'

export default defineConfig({
  markdown: {
    config: (md) => {
      md.use(codeTreeMarkdownPlugin)
    },
  },
})
// .vitepress/theme/index.ts
import type { Theme } from 'vitepress'
import { enhanceAppWithCodeTree } from 'vitepress-plugin-code-tree/client'
import DefaultTheme from 'vitepress/theme'

export default {
  extends: DefaultTheme,
  enhanceApp(ctx) {
    enhanceAppWithCodeTree(ctx)
  },
} satisfies Theme

Syntax

The plugin provides two syntaxes to render a code tree: a container syntax for inline file content, and an embed syntax to load files from a directory.

Container Syntax

Use ::: code-tree container with fenced code blocks inside. Each fence must declare a filename via the [filename] syntax in its info string.

::: code-tree title="Project Structure"

```ts [index.ts]
const a = 1
```

```rs [main.rs]
fn main() {
    println!("Hello, world!");
}
```

:::

Container Attributes

| Attribute | Description | Default | | -------------- | ----------------------------- | ------- | | title | Code tree title | - | | height | Code tree container height | 420px | | entry | Entry file, opened by default | - | | show-sidebar | Show sidebar by default | false |

Active File

Add :active to a fence's info string to mark it as the default active file:

::: code-tree

```ts [index.ts] :active
const a = 1
```

```ts [utils.ts]
export const noop = () => {}
```

:::

Embed Syntax

Use @[code-tree](dir) to embed a directory as a code tree. Files in the directory are loaded and rendered automatically.

@[code-tree](./src)

The dir supports the following prefixes:

| Prefix | Description | | ------ | ------------------------------------------------- | | @ | Relative to VitePress srcDir | | / | Relative to VitePress project root | | - | Relative to the current markdown file's directory |

Embed Attributes

@[code-tree title="Source" height="500px" entry="index.ts" show-sidebar=true](./src)

Options

import codeTree, { loadCodeContent } from 'vitepress-plugin-code-tree'
import { defineConfig } from 'vitepress-tuck'

export default defineConfig({
  plugins: [
    codeTree({
      height: '500px',
      ignores: ['**/*.test.ts'],
      loaders: [
        {
          filter: ['**/*.md'],
          load: (file) =>  loadCodeContent(file, 'md'),
        },
      ],
    }),
  ],
})

| Option | Description | Default | | --------- | ------------------------------------------------------ | ------- | | height | Default code tree container height | 420px | | ignores | Glob patterns to ignore files when loading directories | [] | | loaders | Custom file loaders for embed syntax | [] |

File Loaders

Loaders are used by the embed syntax to load file content. The plugin ships with built-in loaders for common file types (images, config files, source files supported by Shiki). Custom loaders are merged before the built-in ones, so they take precedence.

loaders: [
  {
    filter: ['**/*.md'],
    load: (file) =>  loadCodeContent(file, 'md'),
  },
]

The filter field accepts a glob pattern, an array of glob patterns, or a function that receives a CodeTreeFile and returns a boolean.