metalsmith-collections-convention

v1.3.2
Metalsmith Collections Convention Plugin
metalsmith

Metalsmith Collections Convention Plugin NPM version

Build Status Dependency Status Greenkeeper badge

Metalsmith plugin to allow defining Collections by using file conventions.

Installation

npm install --save metalsmith-collections-convention

CLI

If you are using the command-line version of Metalsmith, you can install via npm, and then add the metalsmith-jstransformer key to your metalsmith.json file:

{
  "plugins": {
    "metalsmith-collection-convention": {}
  }
}

JavaScript

If you are using the JS Api for Metalsmith, then you can require the module and add it to your .use() directives:

var collections = require('metalsmith-collection-convention');

metalsmith.use(collections());

Usage

There are two different methods of define collections. First, by using <name>.collection file convention, or by defining the collection in source file meta-data.

Convention

Each collection is constucted through defining files named <name>.collection.

src/articles.collection

---
pattern: 'articles/*.md'
sortBy: 'date'
reverse: true
---
This is the collection of articles. It is available at:
  metalsmith.metadata().articles

Metadata

You can define which collection source files are placed by placing them in the meta-data.

src/articles/foo.md

---
collection: articles
---
This article will appear in the articles collection. It is available at:
  metalsmith.metadata().articles

src/documents/bar.md

---
collection:
  name: documents
  sortBy: title
---
This article will appear in the documents collection, sorted by title. It is
available at:
  metalsmith.metadata().documents

License

MIT

Metadata

  • MIT
  • Whatever
  • Unknown
  • released 5/7/2018

Downloads

Maintainers