Skip to content

chore: rewrite searchbar indexer for Vocs v2#530

Open
scode2277 wants to merge 1 commit into
developfrom
chore/searchbar-indexer-v2
Open

chore: rewrite searchbar indexer for Vocs v2#530
scode2277 wants to merge 1 commit into
developfrom
chore/searchbar-indexer-v2

Conversation

@scode2277

Copy link
Copy Markdown
Collaborator

In this PR:

  • Rewrote utils/searchbar-indexing.cjs from a re-indexer into a post-processor over Vocs v2's own search index.
  • Re-added it to postdocs:build in package.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 .org site.

What it does now:

  • Instead of rebuilding the index, it takes the one Vocs v2 already correctly generates and filters it in place.
  • Removes files we don't want indexed, like pages that are not in the sidebar or config pages.
  • Removes the dev: true files, so the .org stays clean.
  • Also removes the DevOnly-wrapped headings from the index of the Overview of Each Framework page.

@scode2277 scode2277 self-assigned this Jun 25, 2026
@scode2277 scode2277 added enhancement Updates that improve or refine existing features, user experience, or system performance. fix This PR fixes a bug or resolves an issue labels Jun 25, 2026

@frameworks-volunteer frameworks-volunteer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

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

Labels

enhancement Updates that improve or refine existing features, user experience, or system performance. fix This PR fixes a bug or resolves an issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants