# metalsmith-json-feed

> A Metalsmith plugin for generating a JSON Feed from a collection.

Latest version **1.1.0** (published 2017-11-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install metalsmith-json-feed
pnpm add metalsmith-json-feed
yarn add metalsmith-json-feed
bun add metalsmith-json-feed
```

## 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.1.0 |
| Published | 2017-11-29 |
| First published | 2017-05-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=7.0.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Ben Smithett |
| Maintainers | bensmithett |
| Keywords | metalsmith, metalsmith plugin, json feed, jsonfeed |

## Links

- npm: https://www.npmjs.com/package/metalsmith-json-feed
- Repository: https://github.com/bensmithett/metalsmith-json-feed
- Homepage: https://github.com/bensmithett/metalsmith-json-feed#readme
- Issues: https://github.com/bensmithett/metalsmith-json-feed/issues
- npm.io page: https://npm.io/package/metalsmith-json-feed

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.1.0 (latest) — 2017-11-29
- 1.0.1 — 2017-05-24
- 1.0.0 — 2017-05-23

## README

[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

A [Metalsmith](http://www.metalsmith.io/) plugin for generating a [JSON Feed](https://jsonfeed.org/) from a [collection](https://github.com/segmentio/metalsmith-collections).

`npm install --save metalsmith-json-feed`
or
`yarn add metalsmith-json-feed`

Heavily inspired by [metalsmith-feed](https://github.com/hurrymaplelad/metalsmith-feed).

## Usage

### Basic

```es6
const Metalsmith = require('metalsmith')
const collections = require('metalsmith-collections')
const jsonfeed = require('metalsmith-json-feed')

Metalsmith('example')
  .use(collections({
    posts: '*.html'
  }))
  .use(jsonfeed({
    collection: 'posts',
    title: 'Example feed'
  }))
```

### Using metadata

If your site has `title`, `url` or `author` metadata, they will be used (you can override them by setting options, see below).

```es6
const Metalsmith = require('metalsmith')
const collections = require('metalsmith-collections')
const jsonfeed = require('metalsmith-json-feed')

Metalsmith('example')
  .metadata({
    site: {
      title: 'Example Blog',
      url: 'https://blog.example.biz',
      author: 'Josephine Examplesmith'
    }
  })
  .use(collections({
    posts: '*.html'
  }))
  .use(jsonfeed({
    collection: 'posts'
  }))
```

### Item metadata

Items get their `url` field from the file's path by default. To direct links elsewhere, you can override the URL by providing a `link` metadata entry for a file:

```
---
link: http://example.com
---
This post is an external link.
```

## Options & their defaults

```es6
Metalsmith('example')
  .use(collections({
    posts: '*.html'
  }))
  .use(jsonfeed({
    collection: undefined,
    // (Required)
    // You must set this to the name of the collection you want to generate the feed from ('posts' in this example)

    title: undefined,
    // (Required, unless you supply site.title in metadata - see Metadata example above)
    // The title of your feed.

    destination: 'feed.json',
    // (Optional)
    // The file name you want to generate.

    limit: 20
    // (Optional)
    // Limit the number of items in the feed to the last n

    json: {}
    // (Optional)
    // Any extra JSON Feed fields you want to set manually.
    // Anything set here will override title, url or author values found in metadata.
    // See https://jsonfeed.org/version/1 for the full list.
    // (Don't set `items` though - that's what you're using this plugin to generate)
  }))
```

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