Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@metalsmith/drafts

Package Overview
Dependencies
Maintainers
4
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@metalsmith/drafts

A metalsmith plugin to hide drafts.

  • 1.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

@metalsmith/drafts

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

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.

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:

---
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
      }
    }
  ]
}

License

MIT

Keywords

FAQs

Package last updated on 07 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc