Documented collection metadata feature.

This commit is contained in:
Carl Olsen 2014-09-08 13:33:15 -04:00
parent 0f70d87931
commit 4e61ad200c

View file

@ -19,7 +19,7 @@ There are two ways to create collections:
- **by pattern** - this is just passing a globing pattern that will group any files that match into the same collection.
- **by metadata** - this is adding a specific `collection` metadata field to each item that you want to add to a collection.
The simplest way to create a collection is to use a pattern to match the files you want to group together:
```js
@ -64,6 +64,33 @@ My article contents...
All of the files with a matching `collection` will be added to an array that is exposed as a key of the same name on the global Metalsmith `metadata`.
Additional metadata can be added to the collection object.
```js
metalsmith.use(collections({
articles: {
sortBy: 'date',
reverse: true,
metadata: {
name: 'Articles',
description: 'The Articles listed here...'
}
}
}));
```
Collection metadata can also be assigned from a `json` or `yaml` file.
```js
metalsmith.use(collections({
articles: {
sortBy: 'date',
reverse: true,
metadata: 'path/to/file.json'
}
}));
```
## CLI Usage
All of the same options apply, just add them to the `"plugins"` key in your `metalsmith.json` configuration: