# metalsmith-drafts

> A metalsmith plugin to hide drafts.

Latest version **1.0.0** (published 2019-10-30) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install metalsmith-drafts
pnpm add metalsmith-drafts
yarn add metalsmith-drafts
bun add metalsmith-drafts
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2019-10-30 |
| First published | 2014-02-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 34 |
| Maintainers | f2prateek, ianstormtaylor, segmentio |

## Links

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

## Recent versions

- 1.0.0 (latest) — 2019-10-30
- 0.1.0 — 2018-09-11
- 0.0.1 — 2014-02-05

## README

# @metalsmith/drafts

A metalsmith plugin to hide drafts. Metalsmith will not build a page that is marked as draft.

[![metalsmith: core plugin][metalsmith-badge]][metalsmith-url]
[![npm: version][npm-badge]][npm-url]
[![ci: build][ci-badge]][ci-url]
[![code coverage][codecov-badge]][codecov-url]
[![license: MIT][license-badge]][license-url]

## Installation

NPM:

```bash
npm install @metalsmith/drafts
```

Yarn:

```bash
yarn add @metalsmith/drafts
```

## Usage

Pass the plugin with any options to `metalsmith.use`.

```js
import drafts from '@metalsmith/drafts'

metalsmith.use(drafts()) // same as { include: false }
metalsmith.use(drafts(true)) // same as { include: true }
metalsmith.use(drafts({ default: false, include: false })) // same as default
```

Add `draft: true` to your files' YAML front-matter to mark them as drafts:

```yaml
---
title: My post
draft: true
---
```

To build pages that are marked as draft during development, you can use the Node environment and include the draft page in the build accordingly.

```js
const inDevelopment = process.env.NODE_ENV === 'development'

metalsmith.use(drafts(inDevelopment))
```

### Default value for `draft`

You can instruct `@metalsmith/drafts` to mark files as `draft` by default if they don't have a `draft` property in their front-matter:

```js
import drafts from '@metalsmith/drafts'

metalsmith.use(
  drafts({
    default: true
  })
)
```

### Debug

To enable debug logs, set the `DEBUG` environment variable to `@metalsmith/drafts*`:

```js
metalsmith.env('DEBUG', '@metalsmith/drafts*')
```

Alternatively you can set `DEBUG` to `@metalsmith/*` to debug all Metalsmith core plugins.

### CLI Usage

To use this plugin with the Metalsmith CLI, add `@metalsmith/drafts` to the `plugins` key in your `metalsmith.json` file:

```json
{
  "plugins": [
    {
      "@metalsmith/drafts": {
        "default": false
      }
    }
  ]
}
```

## License

[MIT](LICENSE)

[npm-badge]: https://img.shields.io/npm/v/@metalsmith/drafts.svg
[npm-url]: https://www.npmjs.com/package/@metalsmith/drafts
[ci-badge]: https://github.com/metalsmith/drafts/actions/workflows/test.yml/badge.svg
[ci-url]: https://github.com/metalsmith/drafts/actions/workflows/test.yml
[metalsmith-badge]: https://img.shields.io/badge/metalsmith-core_plugin-green.svg?longCache=true
[metalsmith-url]: http://metalsmith.io
[codecov-badge]: https://img.shields.io/coveralls/github/metalsmith/drafts
[codecov-url]: https://coveralls.io/github/metalsmith/drafts
[license-badge]: https://img.shields.io/github/license/metalsmith/drafts
[license-url]: LICENSE

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