mirror of
https://github.com/vale981/metalsmith-collections
synced 2025-03-05 09:21:39 -05:00
973 B
973 B
metalsmith-collections
A Metalsmith plugin that adds collections of files to the global metadata.
Installation
$ npm install metalsmith-collections
CLI Usage
Install via npm and then add the metalsmith-collections
key to your metalsmith.json
plugins, like so:
{
"plugins": {
"metalsmith-collections": {
"articles": {
"sortBy": "date",
"reverse": true
}
}
}
}
And then in your files themselves, add a collection
and the optional field you want to sort by:
---
title: My Article
collection: articles
date: 2013-02-21
---
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
.
Javascript Usage
Pass the plugin to Metalsmith#use
:
var collections = require('metalsmith-collections');
metalsmith.use(collections());
License
MIT