Compare commits

...

1 Commits

Author SHA1 Message Date
openhands
c327397b8a Fix issue #6408: [Feature]: Add Search Bar to Documentation Site 2025-01-22 14:53:32 +00:00
5 changed files with 82 additions and 0 deletions

View File

@@ -2,6 +2,10 @@
This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.
## Search Functionality
The documentation site includes search functionality powered by Algolia DocSearch. For setup instructions, see [SEARCH_SETUP.md](./SEARCH_SETUP.md).
### Installation
```

53
docs/SEARCH_SETUP.md Normal file
View File

@@ -0,0 +1,53 @@
# Setting Up Search for OpenHands Documentation
This documentation site uses [Algolia DocSearch](https://docsearch.algolia.com/) for its search functionality. To enable search on your local development environment or in production, follow these steps:
## 1. Apply for DocSearch Program
1. Go to the [DocSearch Program](https://docsearch.algolia.com/apply) page
2. Fill out the form with the following details:
- Website URL: https://docs.all-hands.dev
- Email: Your maintainer email
- Repository URL: https://github.com/All-Hands-AI/OpenHands
## 2. Configure Algolia Credentials
Once your application is approved, Algolia will provide you with the following credentials:
- Application ID
- Search-Only API Key
- Index Name
Update these values in `docusaurus.config.ts`:
```typescript
algolia: {
appId: 'YOUR_APP_ID',
apiKey: 'YOUR_SEARCH_API_KEY',
indexName: 'openhands',
// ... other options
}
```
## 3. Crawling Configuration
Algolia will set up a crawler to index your documentation. The crawler configuration will be managed by the Algolia team, but you can request updates to the crawling pattern if needed.
## 4. Local Development
The search functionality will work in your local development environment as long as you have the correct Algolia credentials configured.
## 5. Production Deployment
The search functionality will automatically work in production once you deploy with the correct Algolia credentials.
## Security Note
Never commit the actual Algolia API keys to the repository. Instead:
1. For local development: Use environment variables or a local `.env` file
2. For production: Set the credentials through your deployment platform's environment variables
## Additional Resources
- [Docusaurus Search Documentation](https://docusaurus.io/docs/search)
- [Algolia DocSearch Documentation](https://docsearch.algolia.com/docs/what-is-docsearch)

View File

@@ -62,6 +62,28 @@ const config: Config = {
],
themeConfig: {
image: "img/docusaurus.png",
// Add Algolia search configuration
algolia: {
// Application ID provided by Algolia
appId: 'YOUR_APP_ID',
// Public API key
apiKey: 'YOUR_SEARCH_API_KEY',
// Index name
indexName: 'openhands',
// Optional: see doc section below
contextualSearch: true,
// Optional: Specify domains where the navigation should occur through window.location instead on history.push. Useful when our Algolia config crawls multiple documentation sites and we want to navigate with window.location.href to them.
externalUrlRegex: 'external\\.com|domain\\.com',
// Optional: Replace parts of the item URLs from Algolia. Useful when using the same search index for multiple deployments using a different baseUrl. You can use regexp or string in the `from` param. For example: localhost:3000 vs myCompany.com/docs
replaceSearchResultPathname: {
from: '/docs/', // or as RegExp: /\/docs\//
to: '/',
},
// Optional: Algolia search parameters
searchParameters: {},
// Optional: path for search page that enabled by default (`false` to disable it)
searchPagePath: 'search',
},
navbar: {
title: "OpenHands",
logo: {

View File

@@ -12,6 +12,7 @@
"@docusaurus/plugin-content-pages": "^3.7.0",
"@docusaurus/preset-classic": "^3.7.0",
"@docusaurus/theme-mermaid": "^3.7.0",
"@docusaurus/theme-search-algolia": "^3.7.0",
"@mdx-js/react": "^3.1.0",
"clsx": "^2.0.0",
"prism-react-renderer": "^2.4.1",
@@ -3513,6 +3514,7 @@
"version": "3.7.0",
"resolved": "https://registry.npmjs.org/@docusaurus/theme-search-algolia/-/theme-search-algolia-3.7.0.tgz",
"integrity": "sha512-Al/j5OdzwRU1m3falm+sYy9AaB93S1XF1Lgk9Yc6amp80dNxJVplQdQTR4cYdzkGtuQqbzUA8+kaoYYO0RbK6g==",
"license": "MIT",
"dependencies": {
"@docsearch/react": "^3.8.1",
"@docusaurus/core": "3.7.0",

View File

@@ -19,6 +19,7 @@
"@docusaurus/plugin-content-pages": "^3.7.0",
"@docusaurus/preset-classic": "^3.7.0",
"@docusaurus/theme-mermaid": "^3.7.0",
"@docusaurus/theme-search-algolia": "^3.7.0",
"@mdx-js/react": "^3.1.0",
"clsx": "^2.0.0",
"prism-react-renderer": "^2.4.1",