-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
213 changed files
with
3,167 additions
and
1,503 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# http://editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 2 | ||
# max_line_length = 80 | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
insert_final_newline = false | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.npmrc | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__tests__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ "singleQuote": true, "semi": false, "trailingComma": "none" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
sudo: false | ||
language: node_js | ||
node_js: | ||
- "12.18.2" | ||
- "14.5.0" | ||
cache: npm | ||
script: | ||
- npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Praveen N | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
|
||
# docusaurus-lunr-search | ||
Offline Search for Docusaurus V2 | ||
|
||
[Demo Website](https://praveenn77.github.io/docusaurus-lunr-search-demo/) | ||
|
||
[![MIT Licence](https://img.shields.io/github/license/lelouch77/docusaurus-lunr-search)](#) | ||
|
||
[![npm version](https://badge.fury.io/js/docusaurus-lunr-search.svg)](https://www.npmjs.com/package/docusaurus-lunr-search) | ||
|
||
## Sample | ||
<p align="center"> | ||
<img width="548" alt="image" src="https://github.com/praveenn77/docusaurus-lunr-search/assets/20218070/dbc54b61-077f-4e11-af27-8798cae8a572.gif"> | ||
</p> | ||
|
||
|
||
## Prerequisites | ||
- Docusaurus V2 or V3 | ||
- Node.js >= 12.X | ||
|
||
## How to Use ? | ||
1. Install this package | ||
``` | ||
yarn add docusaurus-lunr-search | ||
``` | ||
or | ||
``` | ||
npm i docusaurus-lunr-search --save | ||
``` | ||
If npm install fails to install with error `unable to resolve dependency tree`, run `npm i --legacy-peer-deps` | ||
|
||
2. Some time npm fails to install `lunr` package, in that case install `lunr` package manually | ||
``` | ||
npm i lunr --save | ||
``` | ||
|
||
3. Add the docusaurus-lunr-search plugin to your `docusaurus.config.js` | ||
``` | ||
module.exports = { | ||
// ... | ||
plugins: [require.resolve('docusaurus-lunr-search')], | ||
} | ||
``` | ||
|
||
4. Then build your Docusaurus project | ||
``` | ||
yarn build | ||
``` | ||
or | ||
``` | ||
npm run build | ||
``` | ||
|
||
5. Serve your application | ||
``` | ||
yarn serve | ||
``` | ||
or | ||
``` | ||
npm run serve | ||
``` | ||
|
||
Note: Docusaurus search information can only be generated from a production build. Local development is currently not supported. | ||
|
||
## Using an option (eg. `languages`) in the plugin | ||
``` | ||
module.exports = { | ||
// ... | ||
plugins: [[ require.resolve('docusaurus-lunr-search'), { | ||
languages: ['en', 'de'] // language codes | ||
}]], | ||
} | ||
``` | ||
Supports all the language listed here https://github.com/MihaiValentin/lunr-languages | ||
|
||
## Options available | ||
|
||
| Option | Type | Default | Description | | ||
| ------------------- | --------- | -------- | ------------------------------------------------------------------------------------------------------------------------- | | ||
| `languages` | `Array` | `['en']` | Language codes to use for stemming, Supports all the language listed here https://github.com/MihaiValentin/lunr-languages | | ||
| `indexBaseUrl` | `Boolean` | `false` | Base url will not indexed by default, if you want to index the base url set this option to `true` | | ||
| `excludeRoutes` | `Array` | `[]` | Exclude certain routes from the search | | ||
| `includeRoutes` | `Array` | `[]` | Include only specific routes for search | | ||
| `stopWords` | `Array` | `[]` | Add stop words(words that are exclude from search result) to the search index | | ||
| `excludeTags` | `Array` | `[]` | Exclude certain tags from the search | ||
| `highlightResult` | `Boolean` | `false` | Enable it to highlight the searched word in the result page. Used `mark.js` for highlighting. <br /> You can customize the highlight color using css <br /> ``` mark { background-color: red !important; color: green !important }``` | | ||
| `disableVersioning` | `Boolean` | `false` | Docs versions are displayed by default. If you want to hide it, set this plugin option to `true` | | ||
| `assetUrl` | `string` | `\` | Url from which the generated search doc files to be loaded, check [issue #122](https://github.com/praveenn77/docusaurus-lunr-search/issues/122) | | ||
| `maxHits` | `string` | `5` | Maximum number of hits shown | | ||
|
||
## Indexing non-direct children headings of `.markdown` | ||
By default, this library will only search for headings that are | ||
**direct children** of the `.markdown` element. | ||
|
||
If you would like to render content inside the `.markdown` element on | ||
a swizzled DocItem component, and want this library to **index the | ||
headings inside those custom elements even if they are not direct | ||
children of the `.markdown` element**, then add the attribute | ||
`data-search-children` to a parent element of the headings you want to | ||
index. | ||
|
||
The `data-search-children` attribute will cause this library to look | ||
for all headings inside that element, including both direct and | ||
indirect children (E.g. 'grandchildren' nodes). | ||
|
||
Check this [issue #115](https://github.com/praveenn77/docusaurus-lunr-search/issues/115) for more details. | ||
|
||
## Upgrading from docusaurus V2 to V3 | ||
Update the `docusaurus-lunr-search` version to `3.3.0` or higher in `package.json` file | ||
|
||
Remove `src/theme/SearchBar` folder if you swizzled it before, if the folder does not exist then ignore this step. | ||
|
||
Do `yarn install` or `npm install` | ||
|
||
If npm install fails to install with error `unable to resolve dependency tree`, run `npm i --legacy-peer-deps` | ||
|
||
## Credits | ||
|
||
Thanks to [`algolia/docsearch.js`](https://github.com/algolia/docsearch), I modified it to create this search component | ||
|
||
And thanks [cmfcmf](https://github.com/cmfcmf), I used the code from his library [docusaurus-search-local](https://github.com/cmfcmf/docusaurus-search-local) for multi-language support. | ||
|
||
## Changelog | ||
Checkout the [releases](https://github.com/lelouch77/docusaurus-lunr-search/releases) page for changelog. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{ | ||
"name": "docusaurus-lunr-search", | ||
"version": "3.3.1", | ||
"description": "Offline search component for Docusaurus V2", | ||
"main": "src/index.js", | ||
"publishConfig": { | ||
"access": "public", | ||
"registry": "https://registry.npmjs.org" | ||
}, | ||
"scripts": { | ||
"test": "mocha '**/__tests__/**/*.spec.js'" | ||
}, | ||
"homepage": "https://github.com/lelouch77/docusaurus-lunr-search/blob/master/README.md", | ||
"repository": { | ||
"url": "https://github.com/lelouch77/docusaurus-lunr-search/" | ||
}, | ||
"author": { | ||
"name": "Praveen N", | ||
"url": "https://github.com/lelouch77" | ||
}, | ||
"contributors": [ | ||
{ | ||
"name": "Pieter C", | ||
"url": "https://github.com/pcallewaert" | ||
}, | ||
{ | ||
"name": "ZachJW34", | ||
"url": "https://github.com/ZachJW34" | ||
}, | ||
{ | ||
"name": "Andrei Rublev", | ||
"url": "https://github.com/anru" | ||
} | ||
], | ||
"keywords": [ | ||
"docusaurus", | ||
"lunr", | ||
"offline-search", | ||
"documentation" | ||
], | ||
"license": "MIT", | ||
"dependencies": { | ||
"autocomplete.js": "^0.37.0", | ||
"clsx": "^1.2.1", | ||
"gauge": "^3.0.0", | ||
"hast-util-select": "^4.0.0", | ||
"hast-util-to-text": "^2.0.0", | ||
"hogan.js": "^3.0.2", | ||
"lunr": "^2.3.8", | ||
"lunr-languages": "^1.4.0", | ||
"mark.js": "^8.11.1", | ||
"minimatch": "^3.0.4", | ||
"rehype-parse": "^7.0.1", | ||
"to-vfile": "^6.1.0", | ||
"unified": "^9.0.0", | ||
"unist-util-is": "^4.0.2" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^8.0.1" | ||
}, | ||
"peerDependencies": { | ||
"@docusaurus/core": "^3.0.0", | ||
"react": "18.2.0", | ||
"react-dom": "^16.8.4 || ^17 || ^18" | ||
}, | ||
"engines": { | ||
"node": ">= 8.10.0" | ||
} | ||
} |
Oops, something went wrong.