Easy, relevant, and efficient client-side search for static sites.
Morsels is a client-side search solution made for static sites, including a search UI and library depending on a pre-built index generated by a CLI tool.
A few other players in this space are Stork and TinySearch. Morsels does the same, with a focus on providing a much more feature rich and customisable search experience, while still being extremely easy to get started with for the simplest of use cases (e.g. static sites).
.json,csv,pdf,html
) to satisfy more custom data requirements.The documentation, which also uses Morsels for its search function, is available here.
Check out the website here as well!
Powering static site search with Morsels is extremely easy, and requires just a folder of your HTML files. Titles, links, headings, etc. are automatically sourced, assuming your folder structure follows how your site's pages are layed out as well.
If you have the rust / cargo toolchains setup, simply run cargo install morsels_indexer --vers 0.6.1
.
Alternatively, download the cli binaries here.
Run the executable as such, replacing <source-folder-path>
with the relative or absolute folder path of your source html files, and <output-folder-path>
with your desired index output folder.
morsels <source-folder-path> <output-folder-path>
Add the following resources to your pages:
```html
```
If you wish to host the files, you can find them in the <output-folder-path>/assets
directory generated by the indexer, or in the releases page.
Give any <input>
element in your page an id
of morsels-search
, then call:
js
initMorsels({
searcherOptions: {
// Output folder url specified as the second parameter in the cli command
// Urls like '/output/' will work as well
url: 'http://<your-domain>/output/',
},
uiOptions: {
// Input / source folder url, specified as the first parameter in the cli command
sourceFilesUrl: 'http://<your-domain>/source/',
}
});
This project is MIT licensed.