Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gitbook-plugin-search

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gitbook-plugin-search

Search integration in GitBook

  • 4.0.0-alpha.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.3K
decreased by-18.31%
Maintainers
2
Weekly downloads
 
Created
Source

This plugin is the interface used by all the search plugins (plugin-lunr, plugin-algolia, etc.)

Registering a Search handler

Your plugin must register as a Search handler during its activate method:

GitBook.createPlugin({
    activate: (dispatch, getState, { Search }) => {
        dispatch(Search.registerHandler('my-plugin-name', searchHandler));
    },
    reduce
})

/**
 * Search against a query
 * @param  {String} query
 * @return {Promise<List<Result>>}
 */
function searchHandler(query, dispatch, getState) {
    ...
}

Your search handler must return a List of result-shaped objects. A result object has the following shape:

result = {
  title: string,  // The title of the resource, as displayed in the list of results.

  url:   string,  // The URL to access the matched resource.

  body:  string   // (optional) The context of the matched text (can be a sentence
                  // containing matching words). It will be displayed near the result.
}

FAQs

Package last updated on 27 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc