-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d2b0919
Showing
11 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
0.0.1 - February 4, 2013 | ||
------------------------ | ||
:sparkles: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
live |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
live |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
draft: true | ||
--- | ||
|
||
draft |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
live |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); | ||
}); |