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

eleventy-plugin-filter-page

v0.2.0

Published

11ty plugin to create collection filter pages

Downloads

446

Readme

eleventy-plugin-filter-page

This Eleventy plugin repository contains two key pieces for "Eleventy Collection Filter" functionality:

  • ecf.plugin.js
  • ecf.filter.js

Examples

Usage

1. Install the plugin

npm install eleventy-plugin-filter-page

2. Add this plugin to your config

eleventyConfig.addPlugin(ecfPlugin);

3. Configure the filters

There are multiple ways to provide configuration to the plugin, but the configuration itself follows the same schema.

Code for a complete 11ty project with an example config and resulting page can be found in the example folder. You can preview the example website here: link eventually.

Configuration schema
interface PluginConfig {
  collection: string; // Name of the Eleventy collection this config applies to 
  identifyingField?: string; // unique field to each item in the collection. Falls back to 'url' when left empty
  filters: Array< // List of filters available for this collection 
  {
    type: "radio";
    label: string; // Human-readable label shown in the UI 
    field: string; // Front-matter field this filter targets 
  } | {
    type: "checkbox";
    label: string;
    field: string;
  } | {
    type: "text";
    label: string;
    field: string;
    /** Optional external <form> ID for wiring into existing markup. See TODO: Step 5 */
    form?: string;
    options?: {
      placeholder?: string; // Placeholder text shown in the input 
    };
  }
  >;
}

3.1 Config as plugin opts

eleventyConfig.addPlugin(ecfPlugin, {
  config: {
    collection: "posts",
    identifyingField: 'url',
    filters: [ /* ... */ ]
  }
});

3.2 Separate file

In case you want to expose your configuration file to a CMS (ex. DecapCMS), you may want to store the configuration in a separate .json file and import it as follows:

eleventyConfig.addPlugin(ecfPlugin, {
  config: require('./src/_data/ecfConfig.json')
});

A sample of DecapCMS config.yml for this purpose can be seen here: config.yml

3.3 _data/ecfConfig.json

Eleventy exposes files in the _data folder as front-matter metadata to the templates. It is also exposed to this plugin, so you can have a config stored in the ecfConfig metadata collection, or if you prefer to name it something else, you can import it as follows:

eleventyConfig.addPlugin(ecfPlugin, {
  configDataField: 'ecfConfig'
});

or rely on ecfConfig default and import the plugin with no further .eleventy.js configuration:

eleventyConfig.addPlugin(ecfPlugin);

4. Create your search page template

Everyone's styling and HTML layout for their 11ty projects is going to be different. This plugin permits you to adjust the template to your liking, as long as the main building blocks are there.

To get the basic version going, just copy the example template file into your source directory and change targetCollection variable, as well as adjust the resultItem macro to match your collection's fields, and you're good to go. For any further modification, rudimentary knowledge of Nunjucks and Eleventy should suffice.

If you have suggestions on how to go about improving this step (architecture or instructions), please submit a Pull Request or open an Issue in this repository.

DecapCMS

In case you want to expose the configuration file to your CMS, here is the DecapCMS's configuration schema that matches the plugin's config schema.

# DecapCMS configuration excerpt.
collections:
  - label: "Configurations"
    name: "configurations"
    files:
      - label: "Filter Configuration"
        name: "ecfConfig"
        file: "src/_data/ecfConfig.json"
        preview_path: /search
        description: "Filter Configuration"
        extension: json
        format: json
        fields:
          - label: "Configuration Items"
            name: "items"
            widget: list
            summary: "Search Page config for Collection: \"{{ fields.collection }}\""
            allow_add: false
            allow_remove: false
            allow_reorder: false
            fields:
              - label: "Collection ID (string)"
                name: "collection"
                hint: "Codename for the collection that will be filtered"
                widget: string
                required: true
              - label: "Identifying Field"
                name: "identifyingField"
                hint: "A unique field to each item in the collection"
                widget: string
                default: 'url'
              - label: "Filters"
                name: filters
                widget: "list"
                label_singular: "filter"
                summary: "{{fields.label }} - {{fields.type }}"
                fields:
                  - label: "Type"
                    name: "type"
                    hint: "Type of input for the filter"
                    widget: select
                    default: "checkbox"
                    options: ['radio', 'checkbox', 'text']
                  - label: "Label"
                    hint: "Display text for a filter"
                    name: "label"
                    widget: string
                    default: ""
                  - label: "Field"
                    name: "field"
                    hint: "Field that the collection will be filtered by (usually lowercase)"
                    widget: string
                    default: ""
                  - label: "External Form ID"
                    name: "form"
                    widget: string
                    hint: "If you are using a custom <form> template, you need to set this string for it to be found by the script"
                    default: ""
                    required: false
                  - label: "Options"
                    name: "options"
                    widget: object
                    default: {}
                    required: false
                    fields:
                      - label: "Placeholder"
                        name: "placeholder"
                        widget: string
                        hint: "Placeholder for text input"