chore: rewrite searchbar indexer for Vocs v2#530
Conversation
…dev/prod search split
frameworks-volunteer
left a comment
There was a problem hiding this comment.
Model: z-ai/glm-5.2 Reasoning: medium Provider: openrouter
Reviewed the rewrite of utils/searchbar-indexing.cjs from a full re-indexer into a post-processor over Vocs v2's own search index, plus the postdocs:build re-addition in package.json.
Security: No concerns. The new Function() eval on line 77 processes the sidebar array from vocs.config.ts — a first-party trusted config containing only plain data (strings, booleans, nested arrays). No template literals or expressions within the sidebar block. The eslint-disable comment documents the rationale. No external input reaches the eval. No secrets, no injection vectors, no suspicious deps.
QA: Changes match the PR description exactly. The bracket-matching parser for the sidebar is a clear improvement over the old line-by-line regex approach — it correctly inherits dev: true from parent groups. The DevOnly heading-stripping logic correctly matches the component usage in overview-of-each-framework.mdx. CI passes (lint, sidebar-reminder, Cloudflare Pages). postdocs:build ordering is correct — searchbar-indexing runs last, after vocs build generates the index.
One minor note (non-blocking): main() has no top-level try/catch (the old async version used .catch()). If readSidebarLinks() throws (e.g., sidebar structure changes), it produces a raw stack trace instead of a clean error message. Functionally equivalent — both exit(1) and fail the build — just slightly less graceful output. Not worth blocking on.
LGTM, approving.
In this PR:
utils/searchbar-indexing.cjsfrom a re-indexer into a post-processor over Vocs v2's own search index.postdocs:buildinpackage.json.Why:
The old script worked around a Vocs v1 bug (its indexer skipped MDX with imports/components). Vocs v2 indexes correctly, but I decided to keep the script because it guarantees that dev files, as well as files not in the sidebar, are not searchable on the
.orgsite.What it does now:
dev: truefiles, so the.orgstays clean.DevOnly-wrapped headings from the index of theOverview of Each Frameworkpage.