Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Metalsmith Snippet

NPM version NPM downloads Build status Test coverage Greenkeeper badge

A Metalsmith plugin for extracting snippets from files.

Installation

npm install metalsmith-snippet --save

Usage

Metalsmith Snippets adds a snippet property to the metadata of every HTML file, when it hasn't already been set.

CLI

Install via npm and then add metalsmith-snippet to your metalsmith.json:

{
  "plugins": {
    "metalsmith-snippet": {
      "maxLength": 300
    }
  }
}

JavaScript

var snippet = require('metalsmith-snippet')

metalsmith.use(snippet({
  stop: ['<span class="more">']
}))

Templates

You can define a custom snippet in your file when you want to provide something more advanced than the auto-generated snippet.

---
title: Example Article
snippet: This is a snippet about my article.
---

Options

  • maxLength The number of characters to keep the snippet within (default: Infinity)
  • suffix The suffix to append to the snippet when the content is trimmed (default: )
  • stop A string or array of strings to search for and trim between (default: null)
  • stripHtml Remove all HTML elements from the snippet (default: true)
  • stripPre Strip the <pre> element from snippet calculation (default: true)

License

MIT

About

A Metalsmith plugin for extracting snippets from files.

Resources

License

Sponsor this project

 

Packages

No packages published
You can’t perform that action at this time.