Skip to main content

Module search

Module search 

Source
Expand description

Client-side search index generator and search UI. Client-side search index generator.

Generates a JSON search index and injects a search UI into HTML pages, providing instant full-text search without any server or external service.

§How it works

  1. At build time, SearchIndex scans all HTML files in the site directory.
  2. It extracts the page title, URL, headings, and body text.
  3. It writes a search-index.json file to the site root.
  4. The SearchPlugin injects a <script> tag and search UI into every HTML page that loads the index and performs client-side fuzzy matching.

The search UI is a modal overlay activated by Ctrl+K / Cmd+K.

Structs§

LocalizedSearchPlugin
Variant of SearchPlugin that injects the widget with caller-supplied localized SearchLabels.
SearchEntry
A single entry in the search index.
SearchIndex
The complete search index written to search-index.json.
SearchLabels
Localizable strings shown in the search widget UI.
SearchPlugin
Plugin that generates a search index and injects client-side search UI.

Constants§

MAX_CONTENT_LENGTH
Maximum content length per page in the search index (characters). Keeps the index compact for fast client-side loading.
MAX_INDEX_ENTRIES
Maximum number of pages to index.