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

@rodavel/tanstack-mdx-tree

v0.3.1

Published

Typed navigation trees from MDX content colocated with TanStack Router routes

Downloads

667

Readme

@rodavel/tanstack-mdx-tree

Vite plugin that generates typed navigation trees from MDX content colocated with your TanStack Router routes.

Why

Colocates MDX documentation with TanStack Router routes following the same file-system conventions. _meta.json files provide display names and ordering per directory. The plugin scans the structure and outputs a typed tree and page map for use in navigation components.

Install

bun add @rodavel/tanstack-mdx-tree

Usage

// vite.config.ts
import { contentTreeGeneratorPlugin } from "@rodavel/tanstack-mdx-tree";

export default defineConfig({
  plugins: [
    contentTreeGeneratorPlugin({
      docsDir: "src/routes/docs",
      outFile: "src/generated/docs-tree.gen.ts",
    }),
  ],
});

The plugin scans docsDir for page files (default index.mdx) with YAML frontmatter, builds a nested navigation tree, and writes it to outFile as a TypeScript module. It regenerates on every content or metadata change during dev.

URL prefix derivation

The URL prefix is derived from docsDir relative to routesDir (default src/routes). For example, src/routes/docs produces the prefix /docs, so a page at src/routes/docs/guides/index.mdx gets the URL /docs/guides.

Root tree node

The root tree node name comes from the root _meta.json file's name field. If no root _meta.json exists, the directory name is used (e.g., docs).

src/routes/docs/
├── _meta.json          # { "name": "Documentation" }
├── index.mdx           # Root page → becomes tree.index
├── guides/
│   ├── _meta.json      # { "name": "Guides", "order": 1 }
│   ├── index.mdx
│   └── setup/
│       └── index.mdx
└── api/
    ├── _meta.json      # { "name": "API Reference", "order": 2 }
    └── index.mdx

Directory metadata (_meta.json)

Each directory can contain a _meta.json file to configure its tree node:

| Field | Type | Description | | --- | --- | --- | | name | string | Display label for the directory node | | order | number | Sort order (lower values appear first) |

Any additional fields are passed through as extra on the DirectoryMeta object:

{
  "name": "Guides",
  "order": 1,
  "icon": "book"
}

Here icon would be available as extra.icon.

Options

Required

| Option | Type | Description | | --- | --- | --- | | docsDir | string | Path to the content directory to scan | | outFile | string | Path where the generated TypeScript file is written |

Optional

| Option | Type | Default | Description | | --- | --- | --- | --- | | routesDir | string | "src/routes" | TanStack Router routes directory, used to derive the URL prefix | | metaFile | string | "_meta.json" | Filename for directory metadata | | pageFile | string | "index.mdx" | Filename to match as a page entry | | enrichPages | (pages, pageByKey) => void | no-op | Callback invoked after scanning and before tree building; mutate pages in place (e.g., inherit fields from ancestors). Receives the pages array and a Map<string, ScannedPage> for O(1) lookups |

CLI

Generate the content tree from the command line using your existing Vite config:

npx content-tree

The CLI reads the contentTreeGeneratorPlugin options from your vite.config.ts and runs the generator. Useful for CI or scripts that need to generate the tree outside of a Vite build.

Compatibility

  • Vite 5+
  • Node.js 18+

License

MIT