Skip to content

Add Algolia DocSearch integration with local search fallback#57

Open
justin808 wants to merge 3 commits intomainfrom
jg/40-ai-docs-search
Open

Add Algolia DocSearch integration with local search fallback#57
justin808 wants to merge 3 commits intomainfrom
jg/40-ai-docs-search

Conversation

@justin808
Copy link
Copy Markdown
Member

@justin808 justin808 commented Mar 25, 2026

Summary

  • Adds conditional Algolia DocSearch support to the Docusaurus config
  • When ALGOLIA_APP_ID, ALGOLIA_SEARCH_API_KEY, and ALGOLIA_INDEX_NAME env vars are set, the site uses Algolia DocSearch with contextual search
  • Without env vars, the existing @easyops-cn/docusaurus-search-local plugin continues to work as before
  • CI workflow passes the Algolia vars (as GitHub repository variables) to both build and deploy jobs

Activation steps

  1. Apply for free Algolia DocSearch at https://docsearch.algolia.com/apply/ (React on Rails qualifies as OSS)
  2. Once approved, add these as GitHub repository variables (Settings > Variables):
    • ALGOLIA_APP_ID
    • ALGOLIA_SEARCH_API_KEY (public search-only key)
    • ALGOLIA_INDEX_NAME
  3. Redeploy — Algolia search activates automatically

Test plan

  • Build passes without Algolia env vars (local search fallback)
  • Verify local search still works on preview deploy
  • Once Algolia keys are set, verify DocSearch activates

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_ID and ALGOLIA_SEARCH_API_KEY are present, themeConfig.algolia is enabled (with contextualSearch) 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

    • Added optional Algolia search integration with environment-driven configuration; site can switch between Algolia-powered search and the existing local search.
    • Included site metadata for Algolia verification and enabled contextual search when Algolia is active.
  • Chores

    • Deployment now propagates Algolia environment variables to the build step.
    • Added ignore rules for local editor napkin files.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 25, 2026

Walkthrough

The 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

Cohort / File(s) Summary
CI: site build & deploy
.github/workflows/site-build-deploy.yml
Added environment variable injection for ALGOLIA_APP_ID, ALGOLIA_SEARCH_API_KEY, and ALGOLIA_INDEX_NAME to the build and deploy job steps.
Docusaurus config: conditional search
prototypes/docusaurus/docusaurus.config.ts
Introduced useAlgolia based on env vars, added localSearchTheme, conditionally populated themes, added Algolia metadata, and conditionally spread an algolia block into themeConfig with appId, apiKey, indexName, and contextualSearch.
Ignore patterns
.gitignore
Added ignore rules for .Codex/napkin.md and .claude/napkin.md.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰
I hopped through CI, leaves in tow,
Sprinkled keys so search can grow,
If envs appear, Algolia sings,
Else local burrows do their things,
Hop—docs found fast, with joy I glow.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The pull request implements conditional Algolia DocSearch support with local search fallback, making search accessible from the navbar and covering all docs content. However, the acceptance criteria for AI-powered answers and CTAs to ShakaCode services remain unaddressed. Verify that the Algolia DocSearch configuration supports AI-powered answers to React on Rails questions and includes CTAs directing users to ShakaCode consulting services. If not implemented, plan these features in a follow-up issue.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add Algolia DocSearch integration with local search fallback' accurately summarizes the main change: enabling Algolia DocSearch with a fallback to local search when Algolia is not configured.
Out of Scope Changes check ✅ Passed All changes are within scope: workflow updates pass Algolia env vars, Docusaurus config conditionally enables Algolia with local fallback, and .gitignore additions exclude local napkin files used during development.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jg/40-ai-docs-search

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

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.

Create PR

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',

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between b02fe8f and b3f937f.

📒 Files selected for processing (2)
  • .github/workflows/site-build-deploy.yml
  • prototypes/docusaurus/docusaurus.config.ts

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 25, 2026

Cloudflare preview deployed.

justin808 and others added 2 commits April 1, 2026 17:06
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>
@justin808 justin808 force-pushed the jg/40-ai-docs-search branch from b3f937f to 6d3498c Compare April 2, 2026 03:22
@justin808
Copy link
Copy Markdown
Member Author

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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

📥 Commits

Reviewing files that changed from the base of the PR and between b3f937f and acb1004.

📒 Files selected for processing (3)
  • .github/workflows/site-build-deploy.yml
  • .gitignore
  • prototypes/docusaurus/docusaurus.config.ts
✅ Files skipped from review due to trivial changes (2)
  • .gitignore
  • .github/workflows/site-build-deploy.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add AI-powered search to help visitors explore docs and connect with ShakaCode

1 participant