Giter Club home page Giter Club logo

postmaker's Introduction

postmaker

The Markdown article generator.

Installation

Install with Yarn...

yarn global add postmaker

...or NPM...

npm install -g postmaker

Usage

Postmaker generates articles through its command-line interface or through a programmatic JavaScript API. Details on how to access the Postmaker interface are below:

Command-Line Interface

The easiest way to get started with Postmaker is by running it through the CLI. Run the postmaker command to generate a Markdown article with front matter data at a given location:

postmaker 'name of the article' -c category -t tag1,tag2,tag3 -p ./src/articles

You can also use it in NPM/Yarn scripts:

{
  "scripts": {
    "generate": "postmaker -p ./src/articles"
  }
}

Running yarn generate 'YOUR ARTICLE NAME' will invoke postmaker and generate your article.

Configuration

Postmaker can also read a .postmakerc file from the current directory, any parent directory, or in any one of the following locations:

  • ~/.config/postmakerc
  • ~/.config/postmaker/postmakerc
  • /etc/postmakerc
  • /etc/postmaker/postmakerc

This is a JSON file that provides defaults for the command-line tool. An example use case is for a project that always generates articles into a certain directory. To prevent having to write -p ./src/articles each time, you could write a .postmakerc config like so:

{
  "path": "./src/articles"
}

Now, every time you invoke postmaker, you can When using it in package.json scripts, make sure you prefix with the binstub path:

{
  "scripts": {
    "generate": "node_modules/.bin/postmaker -p ./src/articles"
  }
}

JavaScript API

Postmaker also exposes a JS API that lets you work with newly generated posts programatically.

To generate a new Post and write it to disk, the easiest method is to use the Postmaker.create() function:

import postmaker from "postmaker"

const post = postmaker.create({
  title: 'name of my post',
  category: 'gbs',
  tags: ['one', 'two']
  path: './src/articles'
})

This creates a new article and writes to disk, using the Post class to store data and make transformations. Most of the library's functionality is implemented in the Post class. Instead of using Postmaker.create(), which will try to write the file to disk before returning the Post object back, you can also instantiate the Post object and manipulate its behavior before writing to disk:

import { Post } from "postmaker"

const post = new Post({
  title: 'name of my post',
  category: 'gbs',
  tags: ['one', 'two']
  path: './src/articles'
})

// ... do some other logic ...

post.write()

Contributing

You can contribute to the development of postmaker by filing an issue report if you're having some trouble using the library/CLI, or submitting a pull request if you have code to fix a particular issue. We accept all contributions that follow our code of conduct.

postmaker's People

Watchers

James Cloos avatar  avatar

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.