1.3.3 • Published 4 years ago

metalsmith-collections-convention v1.3.3

Weekly downloads
25
License
MIT
Repository
github
Last release
4 years ago

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

1.3.3

4 years ago

1.3.2

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.1

8 years ago

1.1.0

9 years ago

1.0.0

9 years ago

0.0.1

9 years ago