Repository navigation
feat: search works in static exports (0.1.15-alpha) - #37
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Search was the last piece of chrome that needed a running Blazor app, so a
shelldocs buildexport had none. Search now runs in the browser, the same way on a running app and on a static host.What changed
/_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 noProgram.cschange. Responses carry an ETag and revalidate.shelldocs.jsdoes the searching.SearchDialogis 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 buildcopies the index to_shelldocs/search.jsonin the export, and warns when the site'sShellDocs.Componentsis too old to serve one.--base-href: the index and result links resolve against<base>.Behaviour changes
[data-search-open]buttons; add the attribute to any element to open search from it.shelldocsSearch.open()still works from script, and there is ashelldocsSearch.close().SearchStateis no longer used and is kept only so existing code compiles.shelldocsSearch.initis gone.Commits
feat(components): serve the search index at /_shelldocs/search.jsonfeat(search): search in the browser, without a Blazor runtimefeat(cli): copy the search index into the static exportdocs: search works in static exportschore: bump to 0.1.15-alpha, changelogEach commit builds with 0 warnings and passes its tests on its own (347 / 350 / 351 / 351 / 351).
Testing
StaticSearchTests).shelldocs buildexport served bypython -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.0.1.15-alphapackages.