mirror of
https://github.com/vale981/metalsmith-collections
synced 2025-03-05 09:21:39 -05:00
Documented collection metadata feature.
This commit is contained in:
parent
0f70d87931
commit
4e61ad200c
1 changed files with 28 additions and 1 deletions
29
Readme.md
29
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 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.
|
- **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:
|
The simplest way to create a collection is to use a pattern to match the files you want to group together:
|
||||||
|
|
||||||
```js
|
```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`.
|
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
|
## CLI Usage
|
||||||
|
|
||||||
All of the same options apply, just add them to the `"plugins"` key in your `metalsmith.json` configuration:
|
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