WeltAn_X on X: "文档站建议加入搜索功能". A search button in the docs'
nav (in the contents bar under 900px), / or Cmd/Ctrl+K, opens a dialog
that finds in the browser: docs-search.js, loaded on first use, reads
/search/<lang>.json once (en, zh, ja; search-index.mjs builds them from
the pages, by section, with the nav's name for each page). Nothing typed
leaves the page; no third-party host. Every term must be found; a
heading counts most, then the page's title, then the text; three
sections a page at most. Arrows or Ctrl+N/P, Enter (this page's section
closes the dialog and jumps), Escape gives focus back. A 120ms fade in,
no movement, nothing under reduced motion; the site's card colour, no
accent.
search.test.mjs fails while a committed index differs from what
search-index.mjs builds, or misses a page, as llms-full's does.
search.browser.mjs (not *.test.mjs, so CI's node --test leaves it out)
drives it in real browsers.
Found on the way: ja's nav made the page 2px too wide at 320px (on main
too); .btn.small takes less padding under 360px.
Run at this head, on mica:
- node --test site/*.test.mjs: 126/126.
- node site/search.browser.mjs: 48/48 (Chromium and WebKit, light and
dark, 1280/900/390/320px, en/zh/ja): nothing loads with the page, one
button shows, no sideways scroll, opening doesn't move the page, the
Download source section is in the top three, Enter to this page and
to another, / and Ctrl/Cmd+K, the scrim, no page errors. Screenshots
looked at in both themes and at 320px.
Broken by hand: a stale ja index makes search.test red; close() without
giving focus back makes the browser test red.