Skip to content

Commit

Permalink
feat: dark theme added
Browse files Browse the repository at this point in the history
  • Loading branch information
praveenn77 committed Aug 19, 2023
1 parent 37251fd commit 44be1f0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 83 deletions.
98 changes: 16 additions & 82 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,18 @@ module.exports = {
npm run build
```
5. Serve your application
```
npm run serve
```
or

```
npx http-server ./build
```

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

## Language options
## Using an option (eg. `languages`) in the plugin
```
module.exports = {
// ...
Expand All @@ -58,89 +63,18 @@ module.exports = {
```
Supports all the language listed here https://github.com/MihaiValentin/lunr-languages

## Other options

### excludeRoutes

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

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

You can include only specific routes for search by using this option:

```
module.exports = {
// ...
plugins: [
[require.resolve('docusaurus-lunr-search'), {
includeRoutes: [
'docs/changelogs/**/*', // include only changelogs from indexing
]
}]
],
}
```

### stopWords

You can add stop words(words that are exclude from search result) to the search index by using this option:
You can find the default list of stop words used by lunrjs [here](https://lunrjs.com/docs/stop_word_filter.js.html)
## Options available

```
module.exports = {
// ...
plugins: [
[require.resolve('docusaurus-lunr-search'), {
stopWords: ['a', 'an', 'the']
}]
],
}
```

### excludeTags

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

```
module.exports = {
// ...
plugins: [
[require.resolve('docusaurus-lunr-search'), {
excludeTags: ['h3'] // exclude h3 tags 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('docusaurus-lunr-search'),
{
indexBaseUrl: true
}
]
],
}
```
| 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 |
| `disableVersioning` | `Boolean` | `false` | Docs versions are displayed by default. If you want to hide it, set this plugin option to `true` |

### disableVersioning
Docs versions are displayed by default. If you want to hide it, set this plugin option to `true`


Thanks to [`algolia/docsearch.js`](https://github.com/algolia/docsearch), I modified it to create this search component
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docusaurus-lunr-search",
"version": "2.4.0",
"version": "2.4.1",
"description": "Offline search component for Docusaurus V2",
"main": "src/index.js",
"publishConfig": {
Expand Down
15 changes: 15 additions & 0 deletions src/theme/SearchBar/algolia.css
Original file line number Diff line number Diff line change
Expand Up @@ -539,3 +539,18 @@
margin-left: auto;
margin-right: 5px;
}

html[data-theme='dark'] .algolia-docsearch-suggestion--category-header,
html[data-theme='dark'] .algolia-docsearch-suggestion--wrapper,
html[data-theme='dark'] .algolia-docsearch-footer {
background: var(--ifm-background-color) !important;
color: var(--ifm-font-color-base) !important;
}

html[data-theme='dark'] .algolia-docsearch-suggestion--title {
color: var(--ifm-font-color-base) !important;
}

html[data-theme='dark'] .ds-cursor .algolia-docsearch-suggestion--wrapper {
background: var(--ifm-background-surface-color) !important;
}

0 comments on commit 44be1f0

Please sign in to comment.