j/rs
Easy, precise, and efficient client-side search for static sites.
Morsels is a complete client-side search solution tailored for static sites, including a search user interface and library that depends on a pre-built index generated by a command-line tool.
Morsels' aim is to provide an easy to set up, yet feature-rich, and efficient search solution for static sites and/or static site generators.
The indexing tool supports a few other file formats (.json
, .csv
, .pdf
, .html
) as well, which can help support more custom data requirements (e.g. linking to another domain).
Check out the demo at https://morsels-search.com!
The documentation, which also uses Morsels for its search function, is available here.
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.
There are two options here:
- If you have the rust / cargo toolchains setup, simply run cargo install morsels_indexer --vers 0.4.1
.
- You can also get 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>
If you are using the binaries, replace morsels
with the appropriate executable name.
Add the following resources to your pages:
```html
```
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.