-
Notifications
You must be signed in to change notification settings - Fork 153
import npm:minisearch #551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
because I was working on the plane ;-) #360 will be the best |
Fil
pushed a commit
that referenced
this pull request
Jan 23, 2024
Fil
pushed a commit
that referenced
this pull request
Jan 29, 2024
Fil
pushed a commit
that referenced
this pull request
Jan 30, 2024
Fil
pushed a commit
that referenced
this pull request
Feb 1, 2024
Fil
pushed a commit
that referenced
this pull request
Feb 1, 2024
mbostock
added a commit
that referenced
this pull request
Feb 14, 2024
* search index as a data loader, search page * copy the lib for now (node_modules/minisearch/dist/es/index.js) * import npm:minisearch (#551) * search in the side bar (WIP) * don't index theme demos… * move css * fix links for index, subfolder * focus on cmd-K * remove unused "category" field * filter out some terms (like long strings with numbers, e.g. API keys) to make the index a bit smaller * remove html tags * index title from front-matter * index.md is / * front-matter title for the intro page * remove hard-coded input * handle ctrl-K * nicer UI * - adds a search option to config - adds a (default) minisearch.json data loader as part of src/ - passes the site root as argv[2] to the data loader * document search * on cmd-K, select the search input contents * use front-matter for title and index options; index h1 if no # was found * this seems to work in all screen widths (?) * cleaner css, optional rendering * DRY * pass root path cleanly * fix ctrl-k again * session storage for the summary open toggle * test * prettier * space * load MiniSearch on demand, fix jumpiness. * Imports of node built-ins should use the node: protocol * remove async cruft; hide menu when showing results * limit to 11 (10+) results * * special route for minisearch.json * default to indexing pages; opt-in and opt-out with front-matter * index on build and dev (with a 10 minutes weak cache) * fix tests * first-of-type (temporary change) * fix two bugs: - when there was no result, we were not saving the state to sessionStorage - the title could be ignored if the source had front-matter (or line feeds) at the top * update documentation * not experimental anymore * fix test (I do want to see that indexed contents) * use parseMardown cleaner text * position search input; add magnifier icon * keyboard navigation * fix tests * prettier * remove observablehq-search-focus from sessionStorage as soon as we've consumed it, so that embedded iframes don't get it ; otherwise they steal the focus! looking specifically at you, /themes! * fix dot colors when navigating on keyboard * Escape on an empty field blurs the input; avoid indirection * oops * fix tests * alias slash * fix tests again * dismantle session navigation * fix typo * fix tests * 10+ results * fix dot position * apply style suggestions from review * fix styles (review comments) * fix next/prev logic on the edge * fix blur * remove italics * fix sidebar opening on small screen * fix tests * fix input style (per @ramonaisonline's design) * don't wrap long titles * fix tests * fix a race condition where you'd try to navigate before the results are ready * on hover, avoid a conflict between the cross (clear input) and the ctrl-K hint * fix a race condition Typically it would happen if you have the search query in the clipboard, type / then paste. The search then didn't execute because when the index arrived (maybe ~500ms), the input event reflecting the paste was gone. * Remove the confusing fuzzy vs. exact dot colors, and trust the relevance score. For large projects we could imagine to have a more complex search panel (or dedicated page), with options such as categories, exact vs. fuzzy match, etc. (Though at some point we'll reach the limits of minisearch). * documentation * prettier * fixes for Safari * fix tests * prettier * 12 bytes * Update src/minisearch.json.ts * Update src/client/search.js Co-authored-by: Mike Bostock <[email protected]> * remove obsolete comment * Update src/client/search.js Co-authored-by: Mike Bostock <[email protected]> * use dynamic import * use safe methods to inject href, title * fix tests * prettier * apply progress-bar design by @ramonaisonline * rollup the minisearch client into the search.js bundle * simpler * conditional search.js deploy * delete undesired search.js * polish * more edits * pretty-ing * more polish * bundle minisearch * more polish * scroll active result into view * docs edits * rename to search.ts * fix import order * copy edit --------- Co-authored-by: Mike Bostock <[email protected]>
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.
Not sure why you didn’t do this in the parent branch; maybe because you wanted to ensure the version of minisearch was the same as the one used to build the index? But I would guess that this should work for the foreseeable future, and also we plan on supporting imports from local modules #360 too… At any rate this seems better than committing a copy to the repo!