Giter Club home page Giter Club logo

drafts's Introduction

@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

drafts's People

Contributors

ianstormtaylor avatar webketje avatar wernerglinka avatar woodyrew avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

drafts's Issues

Tag releases

While the latest version published at https://www.npmjs.com/package/metalsmith-drafts
states that

0.0.1 is the latest release

However there is no such tag in this repository, hence difficult for a developer to see what kind of changes might have happened since.

Please create the tag for the published release.

feature: remove files with the draft extension prefix

The aim of this feature is to allow both a draft version and a "published" version to co-exist, a common use case in existing websites.
A file my-post.md could then co-exist with my-post.draft.md. The file is always removed, but when drafts are enabled the pointer to my-post.md is replaced with the file at my-post.draft.md

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.