New: Introducing PHP and Composer Support.Read the Announcement
Socket
Book a DemoInstallSign in
Socket

gulp-collection

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-collection

Gulp plugin to group vinyl files into a collection and create new vinyl files using pagination and permalinks.

Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

gulp-collection NPM version NPM downloads Build Status

Gulp plugin to group vinyl files into a collection and create new vinyl files using pagination and permalinks.

Install

Install with npm:

$ npm install --save gulp-collection

Usage

This gulp plugin will group together a collection of files based on a property specified in the given permalinks pattern.

var gulp = require('gulp');
var collection = require('gulp-collection');

gulp.task('default', function() {
  return gulp.src('*.hbs')
    .pipe(collection(':tags/:tag.hbs', {
      list: 'Contents to use for listing all the tags',
      item: 'Contents to use for individual tags'
    }))
    .pipe(gulp.dest('dist/'));
});

Files coming through the stream are expected to have a .data property. This is used when grouping to determine how the collection files are created. If your source files have front-matter, you can use gulp-gray-matter to parse the front-matter and add the .data property:

var gulp = require('gulp');
var matter = require('gulp-gray-matter');
var collection = require('gulp-collection');

gulp.task('default', function() {
  return gulp.src('*.hbs')
    .pipe(matter())
    .pipe(collection(':tags/:tag.hbs', {
      list: 'Contents to use for listing all the tags',
      item: 'Contents to use for individual tags'
    }))
    .pipe(gulp.dest('dist/'));
});

Examples

gulpfile.js

The gulpfile.js example shows a simple use case using gulp-gray-matter.

Run the gulpfile example with the following commands:

$ cd examples
$ gulp

advanced.js

The advanced example shows using gulp to read in files, gulp-gray-matter to parse the front-matter and Handlebars to render the templates into html files. This example also shows the use of pagination to create multiple pages from a long list of items.

Run the advanced example with the following commands:

$ cd examples
$ gulp --gulpfile advanced.js

example.js

The example.js example file creates a lot of Vinyl files dynamically and randomly gives them categories and tags. The example streams the dynamically created files through the collection plugin to show how pagination works with a lot of files. This example does not do any file I/O and is run with node directly.

Run the example.js file with the following commands:

$ cd examples
$ node example.js

About

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Building docs

(This document was generated by verb-generate-readme (a verb generator), please don't edit the readme directly. Any changes to the readme must be made in .verb.md.)

To generate the readme and API documentation with verb:

$ npm install -g verb verb-generate-readme && verb

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Brian Woodward

License

Copyright © 2016, Brian Woodward. Released under the MIT license.

This file was generated by verb, v0.9.0, on July 19, 2016.

Keywords

collection

FAQs

Package last updated on 19 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts