From 4e61ad200c91c574de37e882edcff2a1b3e57ebb Mon Sep 17 00:00:00 2001 From: Carl Olsen Date: Mon, 8 Sep 2014 13:33:15 -0400 Subject: [PATCH 1/2] Documented collection metadata feature. --- Readme.md | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index b927664..fec224b 100644 --- a/Readme.md +++ b/Readme.md @@ -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: From 2dab226f28d96aab6d37c972841d87b88037c715 Mon Sep 17 00:00:00 2001 From: Carl Olsen Date: Mon, 8 Sep 2014 13:34:06 -0400 Subject: [PATCH 2/2] added heading --- Readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Readme.md b/Readme.md index fec224b..5041f4b 100644 --- a/Readme.md +++ b/Readme.md @@ -64,6 +64,8 @@ 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`. +### Collection Metadata + Additional metadata can be added to the collection object. ```js