# metalsmith-collections-convention

> Metalsmith Collections Convention Plugin

Latest version **1.3.3** (published 2020-03-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install metalsmith-collections-convention
pnpm add metalsmith-collections-convention
yarn add metalsmith-collections-convention
bun add metalsmith-collections-convention
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.3 |
| Published | 2020-03-04 |
| First published | 2015-07-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 6.6 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | robloach |
| Keywords | metalsmith |

## Links

- npm: https://www.npmjs.com/package/metalsmith-collections-convention
- Repository: https://github.com/kalamuna/metalsmith-collections-convention
- Issues: https://github.com/kalamuna/metalsmith-collections-convention/issues
- npm.io page: https://npm.io/package/metalsmith-collections-convention

## Dependencies (3)

- [extend](https://npm.io/package/extend.md) ^3.0.2
- [minimatch](https://npm.io/package/minimatch.md) ^3.0.4
- [metalsmith-collections](https://npm.io/package/metalsmith-collections.md) ^0.9.0

## Recent versions

- 1.3.3 (latest) — 2020-03-04
- 1.3.2 — 2018-05-07
- 1.3.0 — 2018-02-02
- 1.2.0 — 2017-11-16
- 1.1.1 — 2016-06-28
- 1.1.0 — 2015-07-20
- 1.0.0 — 2015-07-08
- 0.0.1 — 2015-07-06

## README

# Metalsmith Collections Convention Plugin [![NPM version](https://img.shields.io/npm/v/metalsmith-collections-convention.svg)](https://www.npmjs.org/package/metalsmith-collections-convention)

[![Build Status](https://travis-ci.org/kalamuna/metalsmith-collections-convention.svg?branch=master)](https://travis-ci.org/kalamuna/metalsmith-collections-convention)
[![Dependency Status](https://david-dm.org/kalamuna/metalsmith-collections-convention.png)](https://david-dm.org/kalamuna/metalsmith-collections-convention)
[![Greenkeeper badge](https://badges.greenkeeper.io/kalamuna/metalsmith-collections-convention.svg)](https://greenkeeper.io/)

[Metalsmith](http://metalsmith.io) plugin to allow defining [Collections](https://github.com/segmentio/metalsmith-collections) by using file conventions.

## Installation

    npm install --save metalsmith-collections-convention

### CLI

If you are using the command-line version of Metalsmith, you can install via npm, and then add the `metalsmith-jstransformer` key to your `metalsmith.json` file:

```json
{
  "plugins": {
    "metalsmith-collection-convention": {}
  }
}
```

### JavaScript

If you are using the JS Api for Metalsmith, then you can require the module and add it to your `.use()` directives:

```js
var collections = require('metalsmith-collection-convention');

metalsmith.use(collections());
```

## Usage

There are two different methods of define collections. First, by using `<name>.collection` file convention, or by defining the collection in source file meta-data.

### Convention

Each collection is constucted through defining files named `<name>.collection`.

#### `src/articles.collection`
``` yaml
---
pattern: 'articles/*.md'
sortBy: 'date'
reverse: true
---
This is the collection of articles. It is available at:
  metalsmith.metadata().articles
```

### Metadata

You can define which collection source files are placed by placing them in the meta-data.

#### `src/articles/foo.md`
``` yaml
---
collection: articles
---
This article will appear in the articles collection. It is available at:
  metalsmith.metadata().articles
```

#### `src/documents/bar.md`
``` yaml
---
collection:
  name: documents
  sortBy: title
---
This article will appear in the documents collection, sorted by title. It is
available at:
  metalsmith.metadata().documents
```

## License

MIT

---
_Source: https://npm.io/package/metalsmith-collections-convention · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
