newpost v1.1.2
newpost: make GitHub Pages/Jekyll blog posts, faster.
A little utility that creates a blog post file quickly, without copying and pasting front matter. Hate trying to remember what kind of front matter to put in your posts? Can't remember what ISO 8601 date format is to save your life? Install newpost and make managing your Jekyll/GitHub Pages blog posts easier than ever.
How does it work? π
Glad you asked! newpost adds in a custom config object to your package.json that contains front matter for your site. Running newpost init after installing lets you configure your front matter any way you like, and you configure it on a per project basis, so all your sites can have different blog post metadata.
newpost can also take front matter prop:value pairs straight from the command line! You can override properties from your config, as well as adding in any other property you want to have in your front matter for that post.
How to use newpost
Installation π
npm:
npm install newpostYarn:
yarn add newpostSet up front matter π» (Optional)
newpost initThen start adding your metadata. Use this format <property>:<value> when adding front matter, and type q and hit enter when you're done!
Start blogging ππ
You're all set up! If you set up a config object, you can run newpost myNewPostName to create a new blog entry with your default front matter. title is set to myNewPostName by default. The output looks like this:
---
title: myNewPostName
# everything else defined in your config object goes here...
---To override that or any config-defined property, just pass it in as an arg:
newpost myNewPostName --title MyTitle --author Jahziel --coolProp awesomeThis will create a new blog post file called <current ISO 8601 date>.myNewPostName.md, with the following contents:
---
title: myTitle
author: Jahziel
coolProp: awesome
# everything else defined in your config object goes here...
---Make sure you pass in values with spaces in quotes!
newpost myNewPost --title "My really long blog post title" --author Jahziel --coolProp awesomewill give you:
---
title: My really long blog post title
author: Jahziel
coolProp: awesome
# everything else defined in your config object goes here...
-----draft
Adding the --draft flag to any of the above commands will create a draft file instead of a post file. This means that the file will be created in the /_drafts directory instead of the /_posts directory. Additionally, the file will be called post_name.md instead of today-in-ISO8601-post_name.md. Files in the /drafts folder are ignored by Jekyll/GitHub Pages, so you can commit them, but they won't be public. Once you're done crafting the Next Great Blog Entryβ’οΈ, use the undraft command to move your draft to the big leagues (/posts)!
Other commands π
--helpshows a help message with a quick breakdown of whatnewpostdoes!--versionshows the currently installed versionundraft post_namemoves the post with filenamepost_name.mdto the/_postsdirectory. If you don't have a/_posts, it creates it for you.cleanremoves any config data that has been written to package.json
Dev stuff π¨βπ»π©βπ»
Getting started π«
Clone this repo! Then
yarn installor
npm installTesting π§ͺ
There are tests! You can run them! Just run
yarn testor
npm testYou can open up /coverage/index.html to get a detailed coverage report.