From 44be1f05ec09261399837b3f8a34300de7b8eeaa Mon Sep 17 00:00:00 2001 From: Praveen N Date: Sat, 19 Aug 2023 10:19:08 +0530 Subject: [PATCH] feat: dark theme added --- README.md | 98 ++++++--------------------------- package.json | 2 +- src/theme/SearchBar/algolia.css | 15 +++++ 3 files changed, 32 insertions(+), 83 deletions(-) diff --git a/README.md b/README.md index b310690..75c788e 100644 --- a/README.md +++ b/README.md @@ -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 = { // ... @@ -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 diff --git a/package.json b/package.json index b165648..ec28c86 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/theme/SearchBar/algolia.css b/src/theme/SearchBar/algolia.css index 8fa32d1..dc47e34 100644 --- a/src/theme/SearchBar/algolia.css +++ b/src/theme/SearchBar/algolia.css @@ -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; +}