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
$ npm install -g gatsby-post-managergpm is opinionated - it assumes your posts:
- use the
.mdor.mdxfile extensions - have a required
publishedboolean flag in their frontmatter - have an optional
dateattribute (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
$ gpm -d content posts
# or
$ gpm -d content p# status flags: --published, --pending, --unpublished
$ gpm -d content posts --pending
# or
$ gpm -d content p --pending- A post's status is
publishedif itspublishedattribute istrue, and itsdateattribute occurs before or is equal to today's date (if the post has adateattribute) - A post's status is
pendingif itspublishedattribute istrue, and itsdateattribute occurs after today's date (if the post has adateattribute) - A post's status is
publishedif itspublishedattribute istrue, and it does not have adateattribute - A post's status is
unpublishedif itspublishedattribute is nottrue, or doesn't have apublishedattribute at all
$ gpm -d content post-stats
# or
$ gpm -d content ps$ 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

