hugo-lunr-indexer
Version:
Generate Lunr indices for Hugo static sites by parsing front matter.
70 lines (52 loc) • 1.7 kB
Markdown
# [Hugo-Lunr-Indexer (HLI)](https://blog.travismclarke.com/project/hugo-lunr-indexer/)
[](https://www.npmjs.com/package/hugo-lunr-indexer)
[](https://circleci.com/gh/clarketm/hugo-lunr-indexer)
[](LICENSE.md)
Generate [Lunr](https://lunrjs.com/) indexes for [Hugo](https://gohugo.io/) static sites by parsing front matter.
<br>
<br>
<a href="https://blog.travismclarke.com/project/hugo-lunr-indexer/">
<p align="center"><img width="40%" src="/hero.png" /></p>
</a>
## Installation
#### Install with npm
```shell
$ npm install hugo-lunr-indexer
```
## Usage
#### CLI
```shell
###################
# Default options #
###################
$ hli \ # hli -> hugo-lunr-indexer
-i "content/**" \ # input (path)
-o "public/lunr.json" \ # output (path)
-l "toml" # language (toml | yaml)
-d "+++" # delimiter (toml: +++ | yaml: ---)
```
#### NPM Scripts
```javascript
...
"scripts": {
"index": "hli -i 'content/posts/**' -o 'public/indices/lunr.json' -l 'yaml' -d '---'"
},
...
```
```shell
$ npm run index
```
#### API
```javascript
var hli = require('hugo-lunr-indexer');
var Indexer = new hli();
Indexer.setInput('content/blog/**');
Indexer.setOutput('public/static/index.json');
Indexer.setLanguage('toml');
Indexer.setDelimiter('---');
Indexer.index();
```
## Sites using hugo-lunr-indexer
* https://blog.travismclarke.com/
## License
Apache-2.0 © [Travis Clarke](https://www.travismclarke.com/)