Skip to content
This repository has been archived by the owner. It is now read-only.
Metalsmith plugin to include npm modules in your globals.
JavaScript
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
.gitignore
LICENSE
README.md
package.json

README.md

metalsmith-npm

Metalsmith plugin to include npm modules in your globals.

Parameters

"metalsmith-npm": {
    <global variable to use>: <package name in npm to require()>
},

Example Javascript Usage

var npm = require('metalsmith-npm');

metalsmith.use(npm({
    _: "lodash",
    typogr: "typogr"
}));

This is equivalent to:

metalsmith.metadata({
    _: require("lodash"),
    typogr: require("typogr")
});

But is more concise and can be used with a CLI .json configuration, unlike the code above.

Example CLI Usage

"metalsmith-npm": {
    "_": "lodash",
    "typogr": "typogr"
}

Then in your other files you may use the globals, e.g. in archive.jade:

block content
	- var lineHeight = 2.2;
	- var archives = _.chain(articles).groupBy(function(item) {
    ...
You can’t perform that action at this time.