Giter Site home page Giter Site logo

steven-mercatante / gatsby-post-manager Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 557 KB

Gatsby Post Manager helps you quickly see which of your posts are published, pending, and unpublished.

License: MIT License

JavaScript 100.00%
gatsby gatsbyjs command-line-tool command-line

gatsby-post-manager's Introduction

Gatsby Post Manager

npm badge travis badge

Gatsby Post Manager (gpm) is a command line tool that:

  • helps keep track of Gatsby posts, and easily see which ones are published, pending, or unpublished
  • create new posts from a template

Installation

$ npm install -g gatsby-post-manager

Usage

gpm is opinionated - it assumes your posts:

  • use the .md or .mdx file extensions
  • have a required published boolean flag in their frontmatter
  • have an optional date attribute (format: YYYY-MM-DD) in their frontmatter

gpm will recursively search the provided content path (the --dir option) for posts.

Below is my example directory structure. All gpm commands are invoked from the site root.

site/
├── content/
│   ├── posts/
│   |   ├── my-first-post/
│   |   |   └── index.md
│   |   ├── my-second-post/
│   |   |   └── index.mdx
│   |   └── my-third-post.md

List all posts, including their status:

$ gpm -d content posts
# or
$ gpm -d content p

gpm-all-posts

List posts whose status is one of: published, pending, or unpublished

# status flags: --published, --pending, --unpublished
$ gpm -d content posts --pending
# or
$ gpm -d content p --pending

gpm-pending-posts

How does gpm determine post status?

  • A post's status is published if its published attribute is true, and its date attribute occurs before or is equal to today's date (if the post has a date attribute)
  • A post's status is pending if its published attribute is true, and its date attribute occurs after today's date (if the post has a date attribute)
  • A post's status is published if its published attribute is true, and it does not have a date attribute
  • A post's status is unpublished if its published attribute is not true, or doesn't have a published attribute at all

Display post stats:

$ gpm -d content post-stats
# or
$ gpm -d content ps

gpm-all-posts

Create a post:

$ gpm posts new path/to/posts "hello world"

will create a new path/to/posts/hello-world.md file whose frontmatter looks like:

---
title: Hello World
slug: "hello-world"
tags: []
published: false
date: "2019-09-23"
---
Add your content here

gatsby-post-manager's People

Contributors

steven-mercatante avatar

Stargazers

 avatar  avatar

Watchers

 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.