Skip to content

VitePress Plugin Folder Tree

A plugin for VitePress — render beautiful, interactive file/folder tree diagrams from YAML in markdown code blocks.

Quick Start

        • JSONen.json
        • JSONfr.json
        • JSONar.json
        • JSONen.json
        • JSONfr.json
        • JSONar.json
    • JSONen.json
    • JSONfr.json
    • JSONar.json

Code:

yaml
```tree
- name: locales
  children:
    - name: pages
      children:
        - name: index
          children:
            - en.json
            - fr.json
            - ar.json
        - name: about
          children:
            - en.json
            - fr.json
            - ar.json
    - en.json
    - fr.json
    - ar.json
```

Features

  • YAML format — structured, readable, easy to maintain
  • Interactive — Click folders to expand/collapse
  • Search & filter — Find files instantly in large trees
  • Copy as text — Copy tree structure as ASCII art to clipboard
  • Clickable linkshref field makes items navigate to URLs
  • Tree guide lines — Vertical connectors for clear hierarchy
  • Lockablelocked: true prevents toggling a folder
  • Metadatadescription badge, note right-aligned text, highlight, icon
  • Initial stateopen: false starts folder collapsed, global defaultOpen
  • Toolbar — Expand all / Collapse all / Copy / Search (hideable with showToolbar: false)
  • Static modeinteractive: false renders a snapshot with no toggling
  • Validation — Clear YAML error messages at build time
  • Dark Mode — Full VitePress theme support

Installation

bash
pnpm add vitepress-plugin-folder-tree

Setup

1. VitePress config.vitepress/config.mts:

ts
import { defineConfig } from 'vitepress'
import { withFolderTree } from 'vitepress-plugin-folder-tree'

export default withFolderTree(defineConfig({
  title: "My Site",
}))

2. Import styles.vitepress/theme/index.ts:

ts
import DefaultTheme from 'vitepress/theme'
import 'vitepress-plugin-folder-tree/style.css'

export default {
  extends: DefaultTheme,
}

CSS is shipped as a separate file for better performance, caching, and CSP compatibility.

All Node Fields Demo

        • TSengine.ts
        • TSruntime.ts
        • TSauth.ts
        • TSbilling.ts
        • TSnotifications.ts
      • TSindex.tsentrypointupdated today
    • 🔐.envsecret
    • JSONpackage.json
    • 📖README.md

Items with href become clickable links:

Check out the Examples page for more.

Released under the MIT License