Socket
Book a DemoInstallSign in
Socket

assemble-collections

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

assemble-collections

Assemble plugin to add middleware and helpers for working with frontmatter based collections.

latest
Source
npmnpm
Version
0.2.1
Version published
Maintainers
2
Created
Source

assemble-collections NPM version Build Status

Assemble plugin to add middleware and helpers for working with frontmatter based collections.

Install

Install with npm:

$ npm install assemble-collections --save

WARNING

This library has changed to be an assemble plugin as of version 0.2.0.

Usage

var collections = require('assemble-collections');
var app.use(collections());

API

.collections

Add middleware to gather collections from frontmatter and provide helpers for working with collections, collection groups, and views in collection groups.

Params

  • config {Object}: Configuration object for setting up frontmatter collections.
  • config.exts {Array}: Array of extensions to use when adding preRender middleware. Defaults to ['md', 'hbs', 'html'].
  • config.collections {Object}: Optional collections to look for in view frontmatter. Default collections are categories and tags.
  • config.collections.${key} {Object}: Individual collection configuration.
  • config.collections.${key}.inflection {String}: Singular version of collection key: e.g. categories: { inflection: 'category' }
  • config.collections.${key}.sortOrder {String}: Default sort direction of views in each collection. Defaults to asc.

Example

app.use(collections());

collections

Helper to iterate or return an array of frontmatter collection keys.

Example

{{! use as a block helper }}
{{#collections}}
  {{this.name}}
{{/collections}}

{{! use as a subexpression }}
{{#each (collections)}}
  {{this.name}}
{{/each}}

collection

Helper to return the collection instance or iterate over each collection item in the collection.

Example

{{! use as a block helper }}
{{#collection "categories"}}
  <span>{{category}}</span>
  <ul>
    {{#each items}}
      <li>{{name}}</li>
    {{/each}}
  </ul>
{{/collection}}

{{! use as a subexpression }}
{{#each (collection "categories")}}
  <span>{{category}}</span>
  <ul>
    {{#each items}}
      <li>{{name}}</li>
    {{/each}}
  </ul>
{{/each}}

Contributing

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

Building docs

Generate readme and API documentation with verb:

$ npm install verb && npm run docs

Or, if verb is installed globally:

$ verb

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Brian Woodward

License

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

This file was generated by verb, v0.9.0, on April 20, 2016.

FAQs

Package last updated on 20 Apr 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