@metalsmith/drafts v1.3.0
@metalsmith/drafts
A metalsmith plugin to hide drafts. Metalsmith will not build a page that is marked as draft.
Installation
NPM:
npm install @metalsmith/draftsYarn:
yarn add @metalsmith/draftsUsage
Pass the plugin with any options to metalsmith.use.
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 defaultAdd draft: true to your files' YAML front-matter to mark them as drafts:
---
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.
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:
import drafts from '@metalsmith/drafts'
metalsmith.use(
drafts({
default: true
})
)Debug
To enable debug logs, set the DEBUG environment variable to @metalsmith/drafts*:
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:
{
"plugins": [
{
"@metalsmith/drafts": {
"default": false
}
}
]
}