Skip to content

Vlk/fix algolia#1231

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

Vlk/fix algolia#1231
jderochervlk wants to merge 11 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.

AI summary

This pull request introduces Algolia search integration and related infrastructure for the documentation site. It adds a build script to generate and upload a search index to Algolia, updates environment variables and dependencies, and includes supporting type definitions, bindings, and icons. Additionally, it improves URL version parsing and expands test coverage for version detection in URLs.

Algolia Search Integration

  • Added Algolia environment variables (VITE_ALGOLIA_READ_API_KEY, VITE_ALGOLIA_APP_ID, VITE_ALGOLIA_INDEX_NAME) to .env and updated version variables for latest and next documentation versions.
  • Introduced a new build script (scripts/generate_search_index.res) that reads site content, builds Algolia search records, and uploads them using Algolia's API. The script is integrated into the build process via new and updated npm scripts in package.json. [1] [2]
  • Added Algolia SDK as a dependency in package.json.
  • Added ReScript bindings for the Algolia SDK (src/bindings/Algolia.res).
  • Exposed Algolia environment variables in the app via new externals in src/bindings/Env.res.

Search Index Data Model and Utilities

  • Defined the data model and utility functions for search index records in src/common/SearchIndex.resi, including types for hierarchy, weight, and record, as well as functions for building records from various content sources.
  • Updated DocSearch search parameters type to support additional Algolia options such as hitsPerPage, distinct, and attributesToSnippet.

UI Enhancements for Search

  • Added new icon components for search results (e.g., DocPage, DocHash, DocTree, DocSelect) in src/components/Icon.res and their interface in src/components/Icon.resi. [1] [2]

Testing and Version Parsing Improvements

  • Added comprehensive tests for URL version detection, covering various version formats and edge cases in __tests__/Url_.test.res.
  • Improved URL parsing logic to support both v-prefixed and non-prefixed version numbers in src/common/Url.res.
  • Added missing bindings for describe and toEqual in Vitest ReScript bindings, supporting the new tests. [1] [2]

Other Minor Changes

  • Removed the hardcoded DocSearch meta tag for version from the site meta component.

These changes collectively enable robust, up-to-date search capabilities on the documentation site, leveraging Algolia for indexing and querying content.

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)
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 6, 2026

Cloudflare deployment

Deployement ID: 2dee3e42-ffdd-49af-91c7-87141dc1f869
Deployment Environment: preview

⛅️ wrangler 4.63.0 (update available 4.80.0)
─────────────────────────────────────────────
✨ Compiled Worker successfully
Uploading... (7656/7658)
Uploading... (7657/7658)
Uploading... (7658/7658)
✨ Success! Uploaded 2 files (7656 already uploaded) (2.65 sec)

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

@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.

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