@pirxpilot/metalsmith-lunr-index

v1.0.1
Generate lunr indexes with full body search
metalsmith lunr index search

metalsmith-lunr-index

A Metalsmith plugin that integrates the Lunr.js client side search engine.

Builds a searchable JSON index based on Metalsmith metadata.

Made because metalsmith-lunr does not work with Lunr 2.0.

Installation

$ npm install metalsmith-lunr-index

Usage

Include metalsmith-lunr-index in your metalsmith pipeline.

Metalsmith-lunr can be used without options:

var lunr = require('metalsmith-lunr-index');

metalsmith.use(lunr());

Options

By passsing in certain properties, you can change the behaviour.

option meaning
pattern Glob pattern for selecting files to index default: ['**/*.html']
indexPath Output path for the index default: search-index.json
removeStemmer true or false, removes the stemmer from the indexing pipeline
refKey property to be used as ref - if not defined path is used

Client Side Search

Metalsmith-lunr-index will generate search-index.json. Include lunr.js in your javascript source files. Client side search example can be found here.

Once the JSON file has been parsed into javascript, simply run the following:

//index is the parsed JSON file
var idx = lunr.Index.load(index);
var results = idx.search("Your Search Terms Here");
npm i @pirxpilot/metalsmith-lunr-index

Metadata

  • ISC
  • Whatever
  • adenin TECHNOLOGIES
  • released 3/8/2024

Downloads

Maintainers