A fingerprint plugin for Metalsmith
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib switching to a simpler solution Sep 9, 2015
test Added style checker. Dec 24, 2014
.gitignore First commit. Apr 1, 2014
.travis.yml First commit. Apr 1, 2014
LICENSE.md First commit. Apr 1, 2014
README.md Cleanup. Jan 28, 2015
package.json 1.0.3 Sep 9, 2015

README.md

metalsmith-fingerprint

Build Status

A fingerprint plugin for Metalsmith.

Installation

npm install metalsmith-fingerprint

Usage

var fingerprint = require('metalsmith-fingerprint')

Metalsmith(__dirname)
  .use(fingerprint(options))
  .build()

Options

  • match String|Array<String>

    A pattern to filter source files. Required.

Example

Say you want to fingerprint the file css/index.css:

Metalsmith(__dirname)
  .use(fingerprint({ pattern: 'css/index.css' }))
  .use(template({ engine: 'handlebars' }))
  .build()

The plugin does two things:

  1. create a duplicate of index.css with a fingerprinted filename
  2. create a fingerprint object on the Metalsmith metadata

The fingerprint object is accessible from the Handlebars template:

<link href="{{ fingerprint.[css/index.css] }}" rel="stylesheet" type="text/css" />

And the template renders the fingerprinted filename:

<link href="css/index-724af9dd72a48c18dd570790c2445fb4.css" rel="stylesheet" type="text/css" />

Tests

$ npm test

License

See LICENSE.