shrink / metalsmith-collection-grouping

A Metalsmith plugin for grouping collections by a property

Home Page:https://npmjs.com/package/metalsmith-collection-grouping

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

metalsmith-collection-grouping

A Metalsmith plugin for grouping collections by a property.

Installation

$ npm install metalsmith-collection-grouping --save

Usage

var Metalsmith = require('metalsmith')
var collectionGrouping = require('metalsmith-collection-grouping')

var metalsmith = new Metalsmith(__dirname)
  .use(collectionGrouping({
    posts: {
      groupBy: 'category',
      meta: 'posts/categories.json'
    },
    projects: {
      groupBy: 'year',
      meta: {
        2014: {
          title: 'Projects from 2014'
        },
        2014: {
          title: 'Projects from 2014'
        }
      }
    }
  })

The meta property can either accept properties inline or through a json file.

The groups will be available as part of the Metalsmith.metadata(), this plugin does not modify the collections, they will remain as-is.

About

A Metalsmith plugin for grouping collections by a property

https://npmjs.com/package/metalsmith-collection-grouping

License:MIT License


Languages

Language:JavaScript 100.0%