File Tree #
Docs often need to show a project's directory layout. Drawing ├── by hand in a text block gives no icons, no highlighting and no folding, and renaming one file means realigning the lines.
@kawapress/plugin-file-tree lets you write the layout with indentation and renders it at build time as a tree with file icons, folding and annotations. The page carries plain HTML and styles, so the reader's browser downloads no script.
Write a tree #
Write tree as the language of a code block and use indentation for the levels:
```tree
docs/
.kawapress/
guide/
getting-started.md # start here
**routing.md**
kawapress.config.ts
package.json
```The result:
docs/
- .kawapress/
guide/
- getting-started.mdstart here
- routing.md
- kawapress.config.ts
- package.json
Syntax #
packages/
core/
- src/
- package.json
plugin-file-tree/
src/
- index.tsentry
- package.json
Directories open and close on click, and with the keyboard too: focus the directory name and press Enter or Space. Folding uses the browser's native <details>, so no script is involved.
Icons #
Icons come from Catppuccin Icons and are chosen by file name and extension: package.json, .ts, .vue and .md each get their own, and common directory names (src, docs, .github and so on) have dedicated icons. Anything unrecognized gets the generic file or folder icon.
The icons become inline SVG at build time. A page carries only the ones it uses and never calls an online service.
When the indentation is wrong #
Bad indentation fails the build, and the message names the page and the line:
- A level that is not 2 spaces (3 spaces, for example).
- Tabs and spaces mixed in one tree.
- A line indented more than one level deeper than the line above.
- Children under a file (a directory name missing its
/).
Search and llms #
The search index and the llms output read the Markdown source, so they still see the indented text you wrote.
Styles #
The plugin's styles live in the kawa.plugin layer and read only the shared --kawa-* variables, so light and dark follow the theme. To fine-tune, override these classes:
Install #
The nagi preset does not include this plugin, so install it separately:
npm install --save-dev @kawapress/plugin-file-treepnpm add --save-dev @kawapress/plugin-file-treeyarn add --dev @kawapress/plugin-file-treeimport fileTreePlugin from '@kawapress/plugin-file-tree'
import { nagi } from 'kawapress/nagi'
export default nagi({
plugins: [
fileTreePlugin(),
],
})Adding it to plugins is enough. There are no options, and the styles load automatically.
Limitations #
- The plugin renders only what you write. It never reads the real file system to build a tree.
- Links inside a tree are not supported.


Comments