mirror of
https://github.com/vale981/metalsmith-collections
synced 2025-03-05 09:21:39 -05:00
update readme for new features
This commit is contained in:
parent
f573929416
commit
3e181cedda
1 changed files with 46 additions and 3 deletions
49
Readme.md
49
Readme.md
|
@ -1,7 +1,14 @@
|
|||
|
||||
# metalsmith-collections
|
||||
|
||||
A Metalsmith plugin that adds collections of files to the global metadata.
|
||||
A Metalsmith plugin that groups files together into collections and adds them to the global metadata. This is helpful for things like blog posts, where you want to display an index of each.
|
||||
|
||||
## Features
|
||||
|
||||
- can match files by `collection` metadata
|
||||
- can match files by pattern
|
||||
- adds collection to global metadata
|
||||
- adds `next` and `previous` references to each file
|
||||
|
||||
## Installation
|
||||
|
||||
|
@ -9,7 +16,43 @@
|
|||
|
||||
## CLI Usage
|
||||
|
||||
Install via npm and then add the `metalsmith-collections` key to your `metalsmith.json` plugins, like so:
|
||||
|
||||
Install via npm and then add the `metalsmith-collections` key to your `metalsmith.json` plugins.
|
||||
|
||||
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:
|
||||
|
||||
```json
|
||||
{
|
||||
"plugins": {
|
||||
"metalsmith-collections": {
|
||||
"articles": "*.md"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Which is just a shorthand. You could also add additional options:
|
||||
|
||||
```json
|
||||
{
|
||||
"plugins": {
|
||||
"metalsmith-collections": {
|
||||
"articles": {
|
||||
"pattern": "*.md",
|
||||
"sortBy": "date",
|
||||
"reverse": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
But you can also match based on a `collection` property in each file's metadata by omitting a pattern:
|
||||
|
||||
```json
|
||||
{
|
||||
|
@ -45,7 +88,7 @@ My article contents...
|
|||
```js
|
||||
var collections = require('metalsmith-collections');
|
||||
|
||||
metalsmith.use(collections());
|
||||
metalsmith.use(collections('*.md'));
|
||||
```
|
||||
|
||||
## License
|
||||
|
|
Loading…
Add table
Reference in a new issue