A Metalsmith plugin to extract/generate an excerpt from file content or metadata with multiple options.
npm install metalsmith-better-excerptsmetalsmith-better-excerpts
==========================
> A Metalsmith plugin to
> extract/generate an excerpt from file content or metadata with multiple
> options.





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's stripTags and prune functions, although prune can only be used together
with stripTags.
`` sh`
$ npm install metalsmith-better-excerpts
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
}
}
}
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
}));
`
All options are optional.
Set pruneLength to 0 to disable pruning.
` javascript``
var defaultOptions = {
moreRegExp: /\s/i,
stripTags: true,
pruneLength: 140,
pruneString: '…'
};