docs-search
v1.1.42
Published
Offline search component by lunr for Docusaurus V2
Downloads
73
Readme
docs-search
Offline Search by lunr for Docusaurus V2
Prerequisites
worker_thread
is needed, suggested node version > 12.X
How to Use ?
- Install this package
npm i docs-search --save
- Then run
npm install
to update, build, and link the packages
npm install
- Then run docusaurus swizzle
npm run swizzle docs-search SearchBar -- --danger
- Add the docs-search plugin to your
docusaurus.config.js
module.exports = {
// ...
plugins: [require.resolve('docs-search')],
}
- Then build your Docusaurus project
npm run build
- 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