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

@ulu/eleventy-plugin-nav-tree

v0.0.1

Published

An Eleventy plugin to generate a hierarchical navigation tree from a collection, with support for active trail highlighting and collapsible sections.

Downloads

13

Readme

@ulu/eleventy-plugin-nav-tree

An Eleventy plugin to generate a hierarchical navigation tree from a collection. It provides filters for creating the tree structure, converting it to HTML, and filtering it to show only the active trail.

Installation

npm install @ulu/eleventy-plugin-nav-tree --save-dev

Usage

In your Eleventy configuration file (e.g., .eleventy.js), add the plugin:

const navTreePlugin = require("@ulu/eleventy-plugin-nav-tree");

module.exports = function(eleventyConfig) {
  eleventyConfig.addPlugin(navTreePlugin);
};

Filters

This plugin provides three filters for use in your templates.

navTree

Creates a nested tree structure from an Eleventy collection.

Usage:

{% set nav = collections.all | navTree %}

Options: You can pass an options object to override the defaults from defaults.js.

{% set nav = collections.all | navTree({ section: true }) %}

navTreeToHtml

Renders a navigation tree object into an HTML <ul> list.

Usage:

{{ nav | navTreeToHtml | safe }}

Options: You can pass an options object to override the defaults from lib/defaults.js.

{{ nav | navTreeToHtml({ class: "my-menu", collapsible: true }) | safe }}

You can also change the default "Introduction" label by passing the collapsibleIndexLabel option.

{{ nav | navTreeToHtml({ collapsible: true, collapsibleIndexLabel: "Overview" }) | safe }}

A particularly useful option is formatLink, which allows you to customize the link text and markup.

formatLink

The formatLink option is a function that receives an object with the following properties:

  • node: The current node in the navigation tree. The original Eleventy collection item is available at node.entry.
  • options: The options object for the navTreeToHtml filter.
  • isCollapsibleIndex: A boolean that is true only for the special "index" link created inside a collapsible section. This link represents the parent page of the section.

Default formatLink behavior:

function formatLink({ node, options, isCollapsibleIndex }) {
  const { data } = node.entry;
  
  return isCollapsibleIndex ?
    data.menuTitle || options.collapsibleIndexLabel :
    data.menuTitle || data.title;
}

As you can see, when isCollapsibleIndex is true, it defaults to "Introduction" if a menuTitle is not specified in the page's frontmatter. For all other links, it uses the menuTitle or the page's title.

Example of overriding formatLink:

{% set nav = collections.all | navTree %}
{{ nav | navTreeToHtml({
  formatLink: ({ node, isCollapsibleIndex }) => {
    if (isCollapsibleIndex) {
      return `<strong>${node.entry.data.title} (Overview)</strong>`;
    }
    return node.entry.data.title;
  }
}) | safe }}

navTreeActiveTrailOnly

Prunes a navigation tree to only include items that are in the direct path to the currently active page.

Usage:

{% set breadcrumbNav = collections.all | navTree | navTreeActiveTrailOnly %}
{{ breadcrumbNav | navTreeToHtml }}

Links