Automate post creation

This commit is contained in:
Nerian 2013-08-21 17:43:08 +02:00
parent 0bbc5e4884
commit 2eacb24dff
3 changed files with 58 additions and 18 deletions

View file

@ -4,3 +4,5 @@ gem 'jekyll'
gem 'jekyll-minibundle'
gem 'coderay'
gem 'rake'
gem 'thor'
gem 'activesupport'

View file

@ -263,6 +263,16 @@ To make things easier I use LESS to build So Simple Theme's stylesheets. If you
---
## Creating a new Post
You can create a new post like this:
```bash
$ thor post:new 'My cool post'
create _posts/2013-08-21-my-cool-post
```
---
## Questions?
Having a problem getting something to work or want to know why I setup something in a certain way? Ping me on Twitter [@mmistakes](http://twitter.com/mmistakes) or [file a GitHub Issue](https://github.com/mmistakes/so-simple-theme/issues/new).

28
post.thor Normal file
View file

@ -0,0 +1,28 @@
require 'active_support/all'
class Post < Thor
include Thor::Actions
desc "new", "Creates a new post"
argument :title
def new
date = Time.now.strftime("%Y-%m-%d")
create_file "_posts/#{(date + '-' + title).parameterize}.md", <<-eos
---
layout: post
title: #{title}
description: A description
modified: #{date}
category: articles
tags: []
image:
credit:
creditlink:
feature:
comments: true
---
eos
end
end