0.2.0 • Published 7 years ago

metalsmith-lunr-index v0.2.0

Weekly downloads
3
License
ISC
Repository
github
Last release
7 years ago

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 |

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
idx = lunr.Index.load(index)
var results = idx.search("Your Search Terms Here");