docs-search

1.1.42 • Public • Published

docs-search

Offline Search by lunr for Docusaurus V2

Prerequisites

worker_thread is needed, suggested node version > 12.X

How to Use ?

  1. Install this package
npm i docs-search --save
  1. Then run npm install to update, build, and link the packages
npm install
  1. Then run docusaurus swizzle
npm run swizzle docs-search SearchBar -- --danger
  1. Add the docs-search plugin to your docusaurus.config.js
module.exports = {
  // ...
    plugins: [require.resolve('docs-search')],
}
  1. Then build your Docusaurus project
npm run build
  1. Serve your application
npx http-server ./build

Note: Docusaurus search information can only be generated from a production build. Local development is currently not supported.

Language options

module.exports = {
  // ...
    plugins: [[ require.resolve('docs-search'), {
      languages: ['en', 'de'] // language codes
    }]],
}

Other options

excludeRoutes

You can exclude certain routes from the search by using this option:

module.exports = {
  // ...
    plugins: [
    [require.resolve('docs-search'), {
        excludeRoutes: [
            'docs/changelogs/**/*', // exclude changelogs from indexing
        ]
    }]
  ],
}

indexBaseUrl

Base url will not indexed by default, if you want to index the base url set this option to true

module.exports = {
  // ...
    plugins: [
        [require.resolve('docs-search'),
            {
                indexBaseUrl: true
            }
        ]
    ],
}

Thanks to algolia/docsearch.js, I modified it to create this search component

Readme

Keywords

none

Package Sidebar

Install

npm i docs-search

Weekly Downloads

10

Version

1.1.42

License

Senthil

Unpacked Size

68.6 kB

Total Files

16

Last publish

Collaborators

  • clover-utils