mirror of
https://github.com/adulau/brouilleursdeblanc.git
synced 2024-11-21 17:47:10 +00:00
Automate post creation
This commit is contained in:
parent
0bbc5e4884
commit
2eacb24dff
3 changed files with 58 additions and 18 deletions
2
Gemfile
2
Gemfile
|
@ -4,3 +4,5 @@ gem 'jekyll'
|
|||
gem 'jekyll-minibundle'
|
||||
gem 'coderay'
|
||||
gem 'rake'
|
||||
gem 'thor'
|
||||
gem 'activesupport'
|
10
README.md
10
README.md
|
@ -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
28
post.thor
Normal 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
|
Loading…
Reference in a new issue