Draft
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Convert the docs search implementation to use synchronous file I/O and simplify token handling. loadSections() is now synchronous and uses readdirSync/readFileSync; DocSection no longer stores a tokens array and DF computation uses tokenFreq keys. Miscellaneous cleanups include compacting the STOP_WORDS list, inlining section object construction, tightening the BM25 term calculation, simplifying snippet extraction, and small control-flow consolidations. Also updated next.config.mjs to add outputFileTracingIncludes for the /api/chat and /api/mcp routes so the scraped docs are included in tracing.
Add a build script to generate a precomputed search index (scripts/build-search-index.js -> lib/search-index.json) and switch search code to load that JSON at runtime. This removes runtime scraping of public/_scraped-docs, converts tokenFreq to plain records, adds an index cache, refactors BM25/snippet logic, and improves performance and tracing. Also: update next.config to include lib/search-index.json in outputFileTracingIncludes, add lib/search-index.json to .gitignore, and invoke the index build in postbuild.
Improve resilience of search index loading and building. - lib/search-docs.ts: add EMPTY_INDEX and wrap loadIndex in try/catch with validation to return an empty index on missing/invalid search-index.json. - scripts/build-search-index.js: add CONTENT_DIR and helpers (stripMdxNoise, parseYamlScalar, parseSourceMdx, relPathToDocsUrl, walkContentMdxFiles) to parse content/*.mdx, strip MDX import/export noise, and extract frontmatter. Split section building into scraped and content flows, log counts, and fall back to content MDX when scraped docs are absent (avoids Vercel build failures). Add better error handling and messages when no sections are found.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change?
Describe the changes to the documentation
Notes