@rspress/plugin-algolia
This plugin replaces Rspress's built-in search with Algolia through DocSearch.
Installation
Usage
First, add the following configuration to rspress.config.ts:
Then override the Search component with an Algolia-powered search box through Custom Theme.
When @rspress/plugin-webmcp is also enabled, this Search component automatically supplies Algolia results to rspress_search_docs. No additional WebMCP configuration is required.
Configuration
The plugin accepts an options object with the following type:
verificationContent
- Type:
string | undefined - Default:
undefined
Used for meta tag verification when creating an Algolia crawler. Format: <meta name="algolia-site-verification" content="YOUR_VERIFICATION_CONTENT" />. See Create a new crawler - Algolia.
SearchProps
The SearchProps type from @rspress/plugin-algolia/runtime is as follows:
docSearchProps
- Type:
import('@docsearch/react').DocSearchProps - Default:
undefined
docSearchProps is passed directly to the <DocSearch /> component from @docsearch/react. For specific types, see the DocSearch documentation.
locales
- Type:
- Default:
{}
For customizing translated text in different languages, Rspress provides the following translated text for import.
Rspress provides Chinese translations by default, and you can customize translated text for different languages through locales.
- Example:
Algolia crawler config
Here is an example config based on what this site uses:
Distinguish search results based on i18n
You can achieve internationalized search results by combining Runtime API with docSearchProps.
Here's an example using docSearchProps.searchParameters: