Example project which shows how to use ports in elm with a js library.
This demo indexes the full text of Moby Dick, with each paragraph in a separate record. You can find good search terms by looking here.
The search libraries:
The Demos:
This repo should be cloned, then renamed/re-initialized for use in a component.
git clone git@github.com:tommymessbauer/elm-ports-lunr.git your_folder
cd your_folder
yarn run reinstall
yarn run startAfter starting, a local dev server with HMR will be running at localhost:3000. Both examples are available at these urls.
- There is lag in page load b/c the entire text of Moby Dick is indexed on the fly in the browser. In production, you should build the index ahead of time and send it down from the server.
- The elastic lunr example is using
expand=falseand if there are no results, it runsexpand=truewhich loosens the search and gives more results. - Debounce is set to 800ms. Searching is synchronous so it performance is brutal if not debounced.
This is nbd. Fork this repo, then:
- Indexing: replace
data.jsonwith your dataset and tweak the indexing code. - Searching: change the
idx.search(...)parameters to fit your needs.. boosts, wildcards, whatever you like. - Profit.
This is exactly why this project was started. Generally, you can do this:
- update the
pagePath ''in webpack.config.js - run
yarn run build(npm if you like).
- Copy the
tmpfolder to your favorite static file server (github pages, s3, or whatever).