Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

metalsmith-better-excerpts

0.2.1 • Public • Published

metalsmith-better-excerpts

A Metalsmith plugin to extract/generate an excerpt from file content or metadata with multiple options.

npm Package Version MIT License Dependencies Status devDependencies Status Travis Build Status

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's stripTags and prune functions, although prune can only be used together with stripTags.

Installation

$ 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:

{
  "plugins": {
    "metalsmith-better-excerpts": {
      "pruneLength": 80
    }
  }
}

Javascript Usage

Pass options to the plugin and pass it to Metalsmith with the use method:

var excerpts = require('metalsmith-better-excerpts');
 
metalsmith.use(excerpts({
    pruneLength: 80
}));

Options

All options are optional.

Set pruneLength to 0 to disable pruning.

Defaults

var defaultOptions = {
        moreRegExp: /\s*<!--\s*more\s*-->/i,
        stripTags: true,
        pruneLength: 140,
        pruneString: ''
    };

install

npm i metalsmith-better-excerpts

Downloadsweekly downloads

376

version

0.2.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability