mirror of
https://github.com/vale981/metalsmith-collections
synced 2025-03-04 17:01:41 -05:00
Merge pull request #22 from unstoppablecarl/master
Documented collection metadata feature.
This commit is contained in:
commit
d37546ddec
1 changed files with 30 additions and 1 deletions
31
Readme.md
31
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,35 @@ 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
|
||||
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:
|
||||
|
|
Loading…
Add table
Reference in a new issue