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
search #543
search #543
Conversation
This is a neat demo of the power of data loaders! It does feel like the sort of thing you’d want to build into every project, though, not just add it explicitly to a given project. This will be a nice feature to have and I suspect it will be worth it at some point soon! |
4c1e92d
to
deab03f
Compare
b4f6f31
to
ce64331
Compare
… to make the index a bit smaller
- adds a (default) minisearch.json data loader as part of src/ - passes the site root as argv[2] to the data loader
100 commits! |
src/client/search.js
Outdated
@@ -1,4 +1,5 @@ | |||
import MiniSearch from "minisearch"; | |||
// eslint-disable-next-line import/no-relative-packages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, we should find a way to not need this (meaning a bare import should work and resolve to node_modules). Do we not have the node-resolve plugin already? Or is because we’re calling esbuild directly rather than rollup? I thought we were using rollup and supported this already…
src/client/search.js
Outdated
// eslint-disable-next-line import/no-relative-packages | ||
import MiniSearch from "../../node_modules/minisearch/dist/es/index.js"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do rollup with the node-resolve plugin,
https://github.com/observablehq/framework/blob/main/src/rollup.ts#L41
(I have tried various combinations of resolveOnly
—it only ever gets the "src" module. Removing the option altogether doesn't work either.)
the dist/es/index.js is not necessary, using the following works:
// eslint-disable-next-line import/no-relative-packages | |
import MiniSearch from "../../node_modules/minisearch/dist/es/index.js"; | |
// eslint-disable-next-line import/no-relative-packages | |
import MiniSearch from "../../node_modules/minisearch"; |
🤷🏼
I think the test broke because the number of uploaded files changed. Investigating. |
Using minisearch, we create the search index by reading all md contents.
The search is done on the client. The index and the client code are loaded only when the user focuses and starts typing a search query.
closes #166
DONE
search.mp4
Future enhancements, maybe: