Skip to content

fix(search): Update Algolia search to index during build and improve visual display, ranking, and sorting of search results#1231

Draft
jderochervlk wants to merge 19 commits intomasterfrom
vlk/fix-algolia
Draft

fix(search): Update Algolia search to index during build and improve visual display, ranking, and sorting of search results#1231
jderochervlk wants to merge 19 commits intomasterfrom
vlk/fix-algolia

Conversation

@jderochervlk
Copy link
Copy Markdown
Collaborator

@jderochervlk jderochervlk commented Apr 6, 2026

I made it so Algolia gets updated from a script during the build process. This will help keep things up to date. I also changed the way ranking and sorting work so the results feel more target at what we would expect when searching for things like array or array map. There are also some visual changes as the search results show more text and code snippets are inside of <code/> blocks.

Note

This work was done with AI assistance

AI summary

This pull request introduces a major upgrade to the search infrastructure by integrating Algolia-powered site search, including a new build pipeline for generating and uploading search indexes, environment configuration updates, new bindings, and improved URL version parsing. It also adds new test coverage and several utility enhancements.

Algolia Search Integration

  • Added a new build script (scripts/generate_search_index.res) that compiles all site content into Algolia search records and uploads them, with index settings configured for optimal search ranking and faceting. This script is invoked as part of the build process.
  • Introduced new ReScript bindings for the Algolia search client (src/bindings/Algolia.res) to support index upload and configuration from the build script.
  • Updated the build process in package.json to include the search index generation step and added the algoliasearch dependency. [1] [2]

Environment and Configuration

  • Updated .env to include Algolia credentials and index name, and bumped documentation version numbers.
  • Exposed Algolia configuration variables in src/bindings/Env.res for use in the application.

Search Index Utilities

  • Defined a comprehensive API for search record construction and utilities in src/common/SearchIndex.resi, including types and helper functions for content extraction and formatting.

Testing and Utility Improvements

  • Added extensive tests for URL version detection in __tests__/Url_.test.res and improved the version parsing regex in src/common/Url.res to handle both v-prefixed and non-prefixed versions. [1] [2]
  • Improved Vitest bindings to support test grouping and deep equality checks. [1] [2]

UI Enhancements

  • Added new icon components for search result types in src/components/Icon.res and their interface in src/components/Icon.resi. [1] [2]
  • Updated DocSearch search parameter bindings for greater flexibility.
  • Removed hardcoded DocSearch meta tag from src/components/Meta.res to rely on dynamic versioning.

Before

image image

After

image image

….14, tsdown 0.21

Vite ecosystem:
- vite: ^7.0.6 -> ^8.0.3
- @vitejs/plugin-react: ^4.7.0 -> ^6.0.1
- @tailwindcss/vite: ^4.1.13 -> ^4.2.2
- vite-plugin-page-reload: ^0.2.2 -> ^0.2.3

Vitest ecosystem:
- vitest: ^4.0.18 -> ^4.1.2
- @vitest/browser-playwright: ^4.0.18 -> ^4.1.2
- vitest-browser-react: ^2.0.5 -> ^2.2.0

React:
- react: ^19.1.0 -> ^19.2.4
- react-dom: ^19.1.0 -> ^19.2.4
- @types/react: ^19.2.2 -> ^19.2.14

ReScript:
- rescript: ^12.0.0 -> ^12.2.0
- @rescript/react: ^0.14.0 -> ^0.14.2
- Migrate Exn.Error -> JsExn (deprecated in 12.2)

React Router:
- react-router: ^7.12.0 -> ^7.14.0
- react-router-dom: ^7.9.4 -> ^7.14.0
- @react-router/node: ^7.8.1 -> ^7.14.0
- @react-router/dev: ^7.8.1 -> ^7.14.0

tsdown: 0.20.0 -> 0.21.7 (in build:scripts)
@fhammerschmidt
Copy link
Copy Markdown
Member

Cool stuff. btw can you fix the clear button? Looks very weird to me as if the "Clear" text was supposed to be a popover or something.

@jderochervlk jderochervlk changed the title Vlk/fix algolia fix(search): Update Algolia search to index during build and improve visual display, ranking, and sorting of search results Apr 9, 2026
- Hide clear and cancel buttons for cleaner UI
- Redesign footer with border and spacing adjustments
- Add styles for command key display in footer
Update DocSearch commands to show 'to clear' when input has text and 'to close' when empty
@jderochervlk
Copy link
Copy Markdown
Collaborator Author

Cool stuff. btw can you fix the clear button? Looks very weird to me as if the "Clear" text was supposed to be a popover or something.

I removed it and updated the footer to show clear or close with the ESC key depending on if there is text in the search box.

* chore: remove tracked algolia values from env

* feat: finish algolia env split

- centralize public and publisher Algolia env parsing
- disable search clearly when public env is missing
- inject dev/prod Algolia envs in deploy CI
- fix the pre-existing lazy wrapper compile blockers

* Delete docs/superpowers/specs/2026-04-25-algolia-env-split-design.md
Resolve the package.json and yarn.lock conflicts by keeping master's formatting and test updates while preserving the Algolia env split, disabled-search fallback, and search-index build wiring.
Comment thread __tests__/Url_.test.res Outdated
Comment thread src/bindings/Vitest.res Outdated
Comment thread scripts/log_algolia_env_status.mjs Outdated
Comment thread scripts/__tests__/log_algolia_env_status.test.mjs Outdated
Store absolute site URLs in the Algolia index so search records can be parsed outside the app.

Normalize those URLs back to relative paths in the search UI and remove legacy versioned manual path handling from docs links and URL parsing.
Replace the hand-written JS Algolia env status script and its Node test with ReScript modules and a ReScript test.

Run the check from the compiled _scripts output so the build uses the same script pipeline as the rest of the repo.
@jderochervlk
Copy link
Copy Markdown
Collaborator Author

@codex

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 25de384559

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/components/Search.res
Comment thread src/common/SearchIndex.res
Comment thread src/common/SearchIndex.res
@github-actions
Copy link
Copy Markdown

Cloudflare deployment

Deployement ID: 0348236e-f02d-4e88-ad89-8f92d0d1383c
Deployment Environment: preview

⛅️ wrangler 4.63.0 (update available 4.85.0)
─────────────────────────────────────────────
✨ Compiled Worker successfully
Uploading... (8027/8029)
Uploading... (8028/8029)
Uploading... (8029/8029)
✨ Success! Uploaded 2 files (8027 already uploaded) (2.33 sec)

✨ Uploading _redirects
✨ Uploading Functions bundle
🌎 Deploying...
✨ Deployment complete! Take a peek over at https://0348236e.rescript-lang.pages.dev
✨ Deployment alias URL: https://vlk-fix-algolia.rescript-lang.pages.dev

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.

2 participants