Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jonschlinkert/gulp-drafts
Gulp plugin for removing files flagged as drafts. Can also be used as an assemble or verb plugin.
https://github.com/jonschlinkert/gulp-drafts
blog draft gulp ignore-files plugin post published
Last synced: 3 months ago
JSON representation
Gulp plugin for removing files flagged as drafts. Can also be used as an assemble or verb plugin.
- Host: GitHub
- URL: https://github.com/jonschlinkert/gulp-drafts
- Owner: jonschlinkert
- License: mit
- Created: 2014-12-20T14:19:56.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2020-04-01T00:04:31.000Z (almost 5 years ago)
- Last Synced: 2024-10-05T00:21:08.041Z (4 months ago)
- Topics: blog, draft, gulp, ignore-files, plugin, post, published
- Language: JavaScript
- Homepage:
- Size: 7.81 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gulp-drafts [![NPM version](https://badge.fury.io/js/gulp-drafts.svg)](http://badge.fury.io/js/gulp-drafts) [![Build Status](https://travis-ci.org/jonschlinkert/gulp-drafts.svg)](https://travis-ci.org/jonschlinkert/gulp-drafts)
> Gulp plugin for removing files flagged as drafts. Can also be used as an assemble or verb plugin.
The filtering part of the plugin was inspired by [gulp-filter].
## Install with [npm](npmjs.org)
```bash
npm i gulp-drafts --save
```## Usage
_All of the following examples should work in any combination with one another._
### Ignore files using glob patterns
```js
var gulp = require('gulp');
var drafts = require('gulp-drafts');gulp.task('blog', function () {
gulp.src('posts/**/*.md')
// remove files from the pipeline if they match the given
// filepath or glob patterns:
.pipe(drafts('**/drafts/*.md'))
.pipe(gulp.dest('dist'));
});
```### Ignore files with the `draft` property
The plugin automatically filters out files with the `draft` or `data.draft` property set to `true`. Files won't have these properties unless you're setting them on the file object earlier in the pipeline. (_Or, if you're using this plugin with [assemble] or [verb] you can define the `draft` property in front-matter._)
```js
var gulp = require('gulp');
var drafts = require('gulp-drafts');gulp.task('blog', function () {
gulp.src('posts/**/*.md')
// files with {draft: true} or {data: {draft: true}}
// will be removed
.pipe(drafts())
.pipe(gulp.dest('dist'));
});
```### Ignore files with custom properties
```js
var gulp = require('gulp');
var drafts = require('gulp-drafts');gulp.task('blog', function () {
gulp.src('posts/**/*.md')
// ignore files with the `{foo: ...}` or `{bar: {baz: ...}}`
// properties
.pipe(drafts({props: ['foo', 'bar.baz']}))
.pipe(gulp.dest('dist'));
});
```### Verb example
Everything works the same with [verb] and [assemble].
```js
var verb = require('verb');
var drafts = require('verb-drafts');verb.task('blog', function () {
verb.src('posts/**/*.md')
// ignore files with the `{foo: ...}` or `{bar: {baz: ...}}`
// properties
.pipe(drafts({props: ['foo', 'bar.baz']}))
.pipe(verb.dest('dist'));
});
```## Run tests
Install dev dependencies:
```bash
node i -d && mocha
```## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/gulp-drafts/issues)## Author
**Jon Schlinkert**
+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)## License
Copyright (c) 2015 Jon Schlinkert
Released under the MIT license***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 22, 2015._
[gulp-filter]: https://github.com/sindresorhus/gulp-filter