Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ianstormtaylor committed Feb 5, 2014
0 parents commit d2b0919
Show file tree
Hide file tree
Showing 11 changed files with 106 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
4 changes: 4 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

0.0.1 - February 4, 2013
------------------------
:sparkles:
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

node_modules: package.json
@npm install

test: node_modules
@./node_modules/.bin/mocha --reporter spec

.PHONY: test
34 changes: 34 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

# metalsmith-drafts

A metalsmith plugin to hide drafts.

## Installation

$ npm install metalsmith-drafts

## CLI Usage

Install via npm and then add the `metalsmith-drafts` key to your `metalsmith.json` plugins, like so:

```json
{
"plugins": {
"metalsmith-drafts": true
}
}
```

## Javascript Usage

Pass the plugin to `Metalsmith#use`:

```js
var drafts = require('metalsmith-drafts');

metalsmith.use(drafts());
```

## License

MIT
22 changes: 22 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

/**
* Expose `plugin`.
*/

module.exports = plugin;

/**
* Metalsmith plugin to hide drafts from the output.
*
* @return {Function}
*/

function plugin(){
return function(files, metalsmith, done){
setImmediate(done);
Object.keys(files).forEach(function(file){
var data = files[file];
if (data.draft) delete files[file];
});
};
}
13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "metalsmith-drafts",
"description": "A metalsmith plugin to hide drafts.",
"repository": "git://github.com/segmentio/metalsmith-drafts.git",
"version": "0.0.1",
"license": "MIT",
"main": "lib/index.js",
"devDependencies": {
"mocha": "1.x",
"metalsmith": "0.0.0",
"assert-dir-equal": "0.0.1"
}
}
1 change: 1 addition & 0 deletions test/fixture/build/live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
live
1 change: 1 addition & 0 deletions test/fixture/expected/live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
live
5 changes: 5 additions & 0 deletions test/fixture/src/draft.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
draft: true
---

draft
1 change: 1 addition & 0 deletions test/fixture/src/live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
live
16 changes: 16 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

var equal = require('assert-dir-equal');
var Metalsmith = require('metalsmith');
var drafts = require('..');

describe('metalsmith-drafts', function(){
it('should remove drafts from output', function(done){
Metalsmith('test/fixture')
.use(drafts())
.build(function(err){
if (err) return done(err);
equal('test/fixture/expected', 'test/fixture/build');
done();
});
});
});

0 comments on commit d2b0919

Please sign in to comment.