Skip to content

Commit

Permalink
Merge pull request #14 from wernerglinka/master
Browse files Browse the repository at this point in the history
Added conditional draft use in readme file
  • Loading branch information
webketje authored Feb 1, 2022
2 parents 7dceb70 + 13a4ead commit a9ee62a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @metalsmith/drafts

A metalsmith plugin to hide 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]
Expand Down Expand Up @@ -42,6 +42,17 @@ draft: true
---
```

To build pages that are marked as draft during development, use the metalsmith-if plugin to check the node environment and include the draft page in the build accordingly.

```js
const when = require('metalsmith-if');
...
const isProduction = process.env.NODE_ENV === 'production';
...
.use(when(isProduction, drafts()))

```

### 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:
Expand Down

0 comments on commit a9ee62a

Please sign in to comment.