2.0.0-alpha.1 • Public • Published

Client-side Search component

npm version


This uses Lunr.js to perform a client-side search of a site's content. This is recommended only for sites with a limited number of pages.


This consumes a .js file with an object of pages, a la:

let searchIndex = {
  "pages": [
    {"id":"0", "title": "Page title", "text": "Body text of page goes here", "tags": "", "url": "/index.html"},

Warning: Early alpha, lot's of "to do"s

This is an early alpha. More customisation options need to be added, such as:

  • passing search parameters (boost score) to the JS
  • customising the output format
  • NJK template has hardcoded paths for vf-core

Building a search index

  1. Index making code

To generate that JS file, if you're using a vf-eleventy based site, you may also want to make use of the vf-extensions's gulp-build-search-index.js:

require('./node_modules/\@visual-framework/vf-extensions/utils/gulp-build-search-index.js')(gulp, path, buildDestionation);

  1. Dependencies

If you use that JS you'll also need some npm dependencies:

yarn add strip-js striptags node-html-parser

  1. Tell gulp to make the index

And you should build that search index after updating your html pages, a la:

  // build search index after search page is compiled
  gulp.watch(['./build/search/index.html'], gulp.parallel('vf-build-search-index'));

  // And for your `build` task
  gulp.task('build', gulp.series(

  // And for your `dev` task
  gulp.task('dev', gulp.series(

Using search

  • You can pass a query to the search page with ?search_query=myQuery
  • The search will live update as the user enters text
  • You can enable autofocus on the search element, but should only do so if most users intend to search on the page


This repository is distributed with npm. After installing npm, you can install vf-search-client-side with this command.

$ yarn add --dev @visual-framework/vf-search-client-side


The style files included are written in Sass. If you're using a VF-core project, you can import it like this:

@import "@visual-framework/vf-search-client-side/index.scss";

Make sure you import Sass requirements along with the modules. You can use a project boilerplate or the vf-sass-starter



npm i @visual-framework/vf-search-client-side@2.0.0-alpha.1




Apache 2.0

Unpacked Size

35.3 kB

Total Files


Last publish


  • bhushan-ebi
  • pacope92
  • ebiwebdev
  • sandykadam
  • khawkins98