@metalsmith/drafts

A metalsmith plugin to hide drafts.

Usage no npm install needed!

<script type="module">
  import metalsmithDrafts from 'https://cdn.skypack.dev/@metalsmith/drafts';
</script>

README

@metalsmith/drafts

A metalsmith plugin to hide drafts.

metalsmith: core plugin npm: version ci: build code coverage license: MIT

Installation

NPM:

npm install @metalsmith/drafts

Yarn:

yarn add @metalsmith/drafts

Usage

Pass the plugin with any options to Metalsmith.use.

const drafts = require('@metalsmith/drafts')

metalsmith.use(drafts())
metalsmith.use(drafts({ default: false })) // same as default

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

---
title: My post
draft: true
---

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:

const drafts = require('@metalsmith/drafts')

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

CLI Usage

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

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

License

MIT