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

@nera-static/plugin-search

v1.0.3

Published

A plugin for the Nera static site generator that builds a JSON search index and provides a client-side search script.

Downloads

16

Readme

@nera-static/plugin-search

A plugin for the Nera static site generator that adds a lightweight client-side search functionality. It builds a searchable JSON index from your content and provides a ready-to-use search interface – all without requiring a backend.

✨ Features

  • Creates a search-index.json from page content and metadata
  • Fully client-side – no backend or JavaScript framework needed
  • Configurable search fields (e.g., title, excerpt, description)
  • Option to strip HTML from content before indexing
  • Auto-includes search script in assets
  • Includes ready-to-use Pug template with BEM-compatible markup
  • Supports multiple search inputs per page
  • Full compatibility with Nera v4.2.0+

🚀 Installation

Install the plugin in your Nera project:

npm install @nera-static/plugin-search

The plugin is automatically detected and run during the render process.

⚙️ Configuration

Configure the plugin via config/search.yaml (optional):

output_filename: search-index.json

fields:
  - title
  - excerpt
  - content
  - description
  - href

strip_html: true

Field Notes

  • fields: List of metadata fields to include in the index.
  • content: Always pulled from the markdown content itself.
  • strip_html: If true, HTML is removed from content before indexing.

🧩 Usage

Add Search Page

---
title: Search
layout: pages/default.pug
---
.section.search
  h1.search__title Search

  input.search__input(
    type="search",
    placeholder="Search...",
    data-search-input,
    data-results="[data-search__results]"
  )

  ul.search__results(data-search__results)
script(src="/js/search.js")

The plugin will create assets/js/search.js and inject the search-index.json into your /public output.

You can include multiple search inputs on a page by using different [data-results] selectors.

Example Search Result Output

<li class="search__item">
    <a class="search__link" href="${item.href}">${title}</a>
    ${desc ? `<p class="search__description">${desc}</p>` : ''}
</li>

🛠️ Template Publishing

To customize the default view:

npx @nera-static/plugin-search run publish-template

This will copy:

views/vendor/plugin-search/search.pug

to your local project. You can now edit or extend the search markup freely.

The plugin also automatically copies assets/search-content.json to assets/js/search.js on render. This file handles DOM bindings and result generation.

🎨 Styling

Default template uses semantic HTML and includes minimal structure. Recommended BEM class names:

  • .search
  • .search__input
  • .search__results
  • .search__item
  • .search__title
  • .search__description

Customize freely via your own stylesheets.

📊 Generated Output

  • assets/search-index.json: contains all indexed page data
  • assets/js/search.js: minimal client-side logic for filtering and rendering
  • app.searchIndexPath: injected into app data for template access

🧪 Development

npm install
npm test
npm run lint

Tests use Vitest and cover:

  • Index creation from pagesData
  • Correct JSON structure and file writing
  • search.js copy to assets folder
  • Config-driven field control and HTML stripping

🧑‍💻 Author

Michael Becker https://github.com/seebaermichi

🔗 Links

🧩 Compatibility

  • Nera: v4.2.0+
  • Node.js: >= 18
  • Plugin API: Uses getAppData() for index creation and asset copying

📦 License

MIT