Add Algolia DocSearch integration with local search fallback#57
Add Algolia DocSearch integration with local search fallback#57
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
WalkthroughThe CI workflow now injects Algolia environment variables into the site build and deploy steps; the Docusaurus config conditionally enables Algolia search when those variables are present and falls back to a local search theme otherwise. A metadata entry for Algolia verification was also added. Changes
Sequence Diagram(s)sequenceDiagram
participant GH as GitHub Actions
participant Build as Static Site Build (npm run build)
participant Site as Docusaurus config
participant Algolia as Algolia Search
GH->>Build: set env vars (ALGOLIA_APP_ID, ALGOLIA_SEARCH_API_KEY, ALGOLIA_INDEX_NAME)
Build->>Site: run build with env
Site->>Site: evaluate useAlgolia from env
alt useAlgolia = true
Site->>Algolia: configure appId/apiKey/indexName
Site->>Site: include Algolia theme/provider
else
Site->>Site: include local search theme
end
Site->>GH: output built site with chosen search provider
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Partial env vars disable all search functionality
- Updated the Algolia enable guard to require both ALGOLIA_APP_ID and ALGOLIA_SEARCH_API_KEY so local search remains active unless Algolia is fully configured.
Or push these changes by commenting:
@cursor push 1eaa5594a5
Preview (1eaa5594a5)
diff --git a/prototypes/docusaurus/docusaurus.config.ts b/prototypes/docusaurus/docusaurus.config.ts
--- a/prototypes/docusaurus/docusaurus.config.ts
+++ b/prototypes/docusaurus/docusaurus.config.ts
@@ -6,7 +6,7 @@
// Use Algolia DocSearch when configured, otherwise fall back to local search.
// Set ALGOLIA_APP_ID, ALGOLIA_SEARCH_API_KEY, and ALGOLIA_INDEX_NAME env vars
// to activate Algolia. Apply at https://docsearch.algolia.com/apply/
-const useAlgolia = Boolean(process.env.ALGOLIA_APP_ID);
+const useAlgolia = Boolean(process.env.ALGOLIA_APP_ID && process.env.ALGOLIA_SEARCH_API_KEY);
const localSearchTheme: NonNullable<Config['themes']>[number] = [
'@easyops-cn/docusaurus-search-local',There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@prototypes/docusaurus/docusaurus.config.ts`:
- Around line 9-10: Change the Algolia enablement logic so that useAlgolia only
becomes true when all three env vars are present (ALGOLIA_APP_ID,
ALGOLIA_SEARCH_API_KEY, ALGOLIA_INDEX_NAME) instead of only checking
ALGOLIA_APP_ID; update the condition where the Algolia DocSearch config is
applied (the code referencing useAlgolia and the DocSearch/search theme) to keep
the local search theme active as a fallback when useAlgolia is false; ensure any
conditional that currently disables the local search when only partial Algolia
config exists is revised to require the new all-vars check; ask me before
committing changes to the Docusaurus configuration.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 74452a20-f580-47aa-9660-984796615f44
📒 Files selected for processing (2)
.github/workflows/site-build-deploy.ymlprototypes/docusaurus/docusaurus.config.ts
|
Cloudflare preview deployed.
|
When ALGOLIA_APP_ID, ALGOLIA_SEARCH_API_KEY, and ALGOLIA_INDEX_NAME env vars are set, the site uses Algolia DocSearch (with contextual search enabled). Otherwise it falls back to the existing local search plugin seamlessly. CI workflow passes the Algolia vars to both build and deploy jobs. Closes #40 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
b3f937f to
6d3498c
Compare
|
Follow-up on skipped items: I responded inline to the duplicate CodeRabbit thread and left status-only bot posts (review summaries/walkthrough/preview notifications) as no-op since they are non-actionable. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
prototypes/docusaurus/docusaurus.config.ts (1)
6-11: Align activation comment with actual enablement condition.Line 7 says all three env vars are needed, but Line 10 enables Algolia with two vars and uses a default index later. Please update the comment so operators don’t misconfigure deployment.
Suggested comment-only tweak
-// Set ALGOLIA_APP_ID, ALGOLIA_SEARCH_API_KEY, and ALGOLIA_INDEX_NAME env vars -// to activate Algolia. Apply at https://docsearch.algolia.com/apply/ +// Set ALGOLIA_APP_ID and ALGOLIA_SEARCH_API_KEY to activate Algolia. +// ALGOLIA_INDEX_NAME is optional and defaults to 'reactonrails'. +// Apply at https://docsearch.algolia.com/apply/🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@prototypes/docusaurus/docusaurus.config.ts` around lines 6 - 11, The activation comment is out of sync with the actual enablement check: update the comment above the useAlgolia declaration to reflect that only ALGOLIA_APP_ID and ALGOLIA_SEARCH_API_KEY are required (ALGOLIA_INDEX_NAME is optional and a default index may be used), mentioning the exact env var names and that ALGOLIA_INDEX_NAME is optional so operators don’t misconfigure. Reference the useAlgolia constant and the env vars ALGOLIA_APP_ID, ALGOLIA_SEARCH_API_KEY, and ALGOLIA_INDEX_NAME when editing the comment.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@prototypes/docusaurus/docusaurus.config.ts`:
- Around line 6-11: The activation comment is out of sync with the actual
enablement check: update the comment above the useAlgolia declaration to reflect
that only ALGOLIA_APP_ID and ALGOLIA_SEARCH_API_KEY are required
(ALGOLIA_INDEX_NAME is optional and a default index may be used), mentioning the
exact env var names and that ALGOLIA_INDEX_NAME is optional so operators don’t
misconfigure. Reference the useAlgolia constant and the env vars ALGOLIA_APP_ID,
ALGOLIA_SEARCH_API_KEY, and ALGOLIA_INDEX_NAME when editing the comment.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0645ed7e-faf0-40e3-a1f3-f3c04a9a9d28
📒 Files selected for processing (3)
.github/workflows/site-build-deploy.yml.gitignoreprototypes/docusaurus/docusaurus.config.ts
✅ Files skipped from review due to trivial changes (2)
- .gitignore
- .github/workflows/site-build-deploy.yml


Summary
ALGOLIA_APP_ID,ALGOLIA_SEARCH_API_KEY, andALGOLIA_INDEX_NAMEenv vars are set, the site uses Algolia DocSearch with contextual search@easyops-cn/docusaurus-search-localplugin continues to work as beforeActivation steps
ALGOLIA_APP_IDALGOLIA_SEARCH_API_KEY(public search-only key)ALGOLIA_INDEX_NAMETest plan
Closes #40
🤖 Generated with Claude Code
Note
Low Risk
Config-only changes gated by environment variables; primary risk is misconfiguration causing search to be missing or incorrectly wired in deployments.
Overview
Adds optional Algolia DocSearch to the Docusaurus site: when
ALGOLIA_APP_IDandALGOLIA_SEARCH_API_KEYare present,themeConfig.algoliais enabled (withcontextualSearch) and the local search theme is disabled; otherwise the existing local search plugin remains active.Updates the GitHub Actions site build/deploy workflow to pass Algolia configuration via GitHub repository variables during
npm run build, adds an Algolia site verification meta tag, and ignores AI “napkin” notes in.gitignore.Written by Cursor Bugbot for commit acb1004. This will update automatically on new commits. Configure here.
Summary by CodeRabbit
New Features
Chores