https://github.com/simbo/metalsmith-better-excerpts
A Metalsmith plugin to extract/generate an excerpt from file content or metadata with multiple options.
https://github.com/simbo/metalsmith-better-excerpts
Last synced: 12 months ago
JSON representation
A Metalsmith plugin to extract/generate an excerpt from file content or metadata with multiple options.
- Host: GitHub
- URL: https://github.com/simbo/metalsmith-better-excerpts
- Owner: simbo
- License: mit
- Created: 2014-12-21T21:04:27.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2018-05-20T09:29:18.000Z (about 8 years ago)
- Last Synced: 2024-10-29T06:06:05.470Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 26.4 KB
- Stars: 7
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
metalsmith-better-excerpts
==========================
> A [Metalsmith](https://github.com/segmentio/metalsmith) plugin to
> extract/generate an excerpt from file content or metadata with multiple
> options.
[](https://www.npmjs.com/package/metalsmith-better-excerpts)
[](http://simbo.mit-license.org)
[](https://david-dm.org/simbo/metalsmith-better-excerpts)
[](https://david-dm.org/simbo/metalsmith-better-excerpts#info=devDependencies)
[](https://travis-ci.org/simbo/metalsmith-better-excerpts)
## About
***metalsmith-better-excerpts*** will generate an excerpt for each *file* object
either from frontmatter/metadata, from content until the first `more` tag or
from the first paragraph in content. So generated excerpt content can be
additionally parsed by
[underscore.string](https://github.com/epeli/underscore.string)'s
`stripTags` and `prune` functions, although `prune` can only be used together
with `stripTags`.
## Installation
``` sh
$ npm install metalsmith-better-excerpts
```
## CLI Usage
Install via npm and then add the metalsmith-better-excerpts key to your
_metalsmith.json_ with any options you want, like so:
``` json
{
"plugins": {
"metalsmith-better-excerpts": {
"pruneLength": 80
}
}
}
```
## Javascript Usage
Pass options to the plugin and pass it to Metalsmith with the use method:
``` javascript
var excerpts = require('metalsmith-better-excerpts');
metalsmith.use(excerpts({
pruneLength: 80
}));
```
## Options
All options are optional.
Set `pruneLength` to `0` to disable pruning.
### Defaults
``` javascript
var defaultOptions = {
moreRegExp: /\s*/i,
stripTags: true,
pruneLength: 140,
pruneString: '…'
};
```