Skip to content

feat: search works in static exports (0.1.15-alpha) - #37

Merged
Shewart merged 5 commits into
mainfrom
feat/static-search
Oct 11, 2026
Merged

Shewart merged 5 commits into
mainfrom
feat/static-search

Conversation

@Shewart

@Shewart Shewart commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Search was the last piece of chrome that needed a running Blazor app, so a shelldocs build export had none. Search now runs in the browser, the same way on a running app and on a static host.

What changed

  • The app serves its search index at /_shelldocs/search.json (title, description, section, body and owning version per entry). It is added by a startup filter, like the redirect map, so sites need no Program.cs change. Responses carry an ETag and revalidate.
  • shelldocs.js does the searching. SearchDialog is now a hidden template with no Blazor handlers. On Cmd/Ctrl+K or a [data-search-open] button, the script clones it onto <body>, fetches the index once and ranks it with the same scoring as before (title, section, description, body, with body snippets), scoped to the current version. Results are links.
  • shelldocs build copies the index to _shelldocs/search.json in the export, and warns when the site's ShellDocs.Components is too old to serve one.
  • Works under --base-href: the index and result links resolve against <base>.

Behaviour changes

  • Search buttons are [data-search-open] buttons; add the attribute to any element to open search from it. shelldocsSearch.open() still works from script, and there is a shelldocsSearch.close().
  • SearchState is no longer used and is kept only so existing code compiles. shelldocsSearch.init is gone.

Commits

  • feat(components): serve the search index at /_shelldocs/search.json
  • feat(search): search in the browser, without a Blazor runtime
  • feat(cli): copy the search index into the static export
  • docs: search works in static exports
  • chore: bump to 0.1.15-alpha, changelog

Each commit builds with 0 warnings and passes its tests on its own (347 / 350 / 351 / 351 / 351).

Testing

  • Release build: 0 warnings. 351 tests pass, 8 of them new (StaticSearchTests).
  • Example site in the browser, three ways: running app, shelldocs build export served by python -m http.server, and the export under a /sub/ base href. In each: Cmd/Ctrl+K, search button, typing, arrow keys, Enter, Escape, backdrop click, and version scoping on unversioned and versioned pages.
  • Keystrokes were sent by script. The dialog has not been checked by eye or at phone width.
  • Pack produces the six 0.1.15-alpha packages.

@Shewart
Shewart merged commit 04e1c04 into main Oct 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant