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 🙏

© 2024 – Pkg Stats / Ryan Hefner

apostrophe-search

v0.5.8

Published

Implements sitewide search for Apostrophe sites

Downloads

10

Readme

Deprecated for new sites

This module was for A2 0.5.x. For new projects, use Apostrophe 2, which has a built-in search module.

apostrophe-search

This module adds a user interface for sitewide search to A2 sites.

Installation

npm install apostrophe-search

Activating the Module

In app.js, in your modules section:

    apostrophe-search: {}

Adding the mini-form to your layout

Just use a cross-module include:

{% include "search:miniForm.html" %}

Adding the search results page to your site

It's already there. Currently the apostrophe:reset task creates one and gives it the slug /search.

Customizing the search results page

Create lib/modules/apostrophe-search/views and copy index.html from this module's views folder to that folder. Then edit as you see fit. Your override will automatically be recognized. It works just like overriding the blog module, snippets module, et cetera.

Customizing the mini-form

Copy miniForm.html in the same way. Or just write your own form directly in your layout. You must use the GET method and the user's search text must be in the q query parameter. The action of your form should be /search.

Customizing the Search Filters

By default filters are displayed which can be used to filter out various results such as blog posts, events, etc. until the user is left with the results they wanted.

By default the list is very complete. The search module emits an addSearchFilters event on the apos object, passing an array as the first argument, and modules that are interested in having a search filter simply push page type names onto that array.

If you wish to restrict the list of filters on your site you can pass a searchFilters option when configuring the module in app.js. Here the only filters provided are for blog posts and "pages."

Note that the filter with the name "other" actually matches everything not matched by your other filters. We label this filter "pages" because it is less confusing for the user.

    apostrophe-search: {
      filters: [
        {
          name: 'other',
          label: 'Pages'
        },
        {
          name: 'blogPost',
          label: 'Articles'
        }
      ]
    }

You can also shut off filters entirely for a project:

    apostrophe-search: {
      filters: false
    }

You should use false, not an empty array.

Styles

Sample styles are available in the sandbox project in public/css/search.less.