Added newpost script

This commit is contained in:
Panos Sakkos 2015-10-18 21:17:55 +02:00
parent ab0389e1b8
commit 8b0d926494
2 changed files with 29 additions and 3 deletions

View file

@ -5,17 +5,30 @@ title: Writing posts
category: tech
tags: [ 'tutorial' ]
---
Run the /scripts/newpost script with the file name of the post as an argument:
<pre style="text-align: left">
cd <your { personal } repo>
./scripts/newpost hello-world
</pre>
A a new post template with name YYYY-MM-DD-hello-world.markup will be created under ./_posts, with the current date.
In the created post, just replace the Title, Category and tags and you can
start writing your post in markdown right bellow the end of the post header.
Every file with the format <i>YYYY-MM-DD-post-title.markup</i> will be processed as a
post, with publication date <i>YYYY-MM-DD</i>.
Make sure that its content starts with:
The content starts with:
<pre style="text-align: left">
---
layout: post
section-type: post
title: My post's title
category: Tutorials
title: Title
category: Category
tags: [ 'tag1', 'tag2' ]
---
</pre>

13
scripts/newpost Executable file
View file

@ -0,0 +1,13 @@
#!/usr/bin/ruby
require 'date'
POSTS_DIR = '_posts/'
post = ARGV[0]
File.open(POSTS_DIR + Date.today.strftime("%Y-%m-%d-") + post + '.markup', 'w') {|f| f.write(
"---\nlayout: post\nsection-type: post\ntitle: <Title>\ncategory: <Category>\ntags: [ '<tag1>', '<tag2>' ]\n---")
}
puts('[+] Created ' + post + ' post')