1.0.3 • Published 10 years ago
metalsmith-fingerprint v1.0.3
metalsmith-fingerprint
A fingerprint plugin for Metalsmith.
Installation
npm install metalsmith-fingerprintUsage
var fingerprint = require('metalsmith-fingerprint')
Metalsmith(__dirname)
.use(fingerprint(options))
.build()Options
matchString|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:
- create a duplicate of
index.csswith a fingerprinted filename - create a
fingerprintobject 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 testLicense
See LICENSE.
