Add category to rake new_post
This commit is contained in:
parent
938c653c71
commit
0cdcde10bf
5 changed files with 6 additions and 20 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -4,5 +4,4 @@ _site
|
|||
*.sublime-workspace
|
||||
codekit-config.json
|
||||
node_modules
|
||||
_asset_bundler_cache
|
||||
Gemfile.lock
|
||||
_asset_bundler_cache
|
8
Gemfile
8
Gemfile
|
@ -1,8 +0,0 @@
|
|||
source 'https://rubygems.org'
|
||||
|
||||
gem 'jekyll'
|
||||
gem 'kramdown'
|
||||
gem 'coderay'
|
||||
gem 'rake'
|
||||
gem 'activesupport'
|
||||
gem 'stringex'
|
|
@ -25,6 +25,7 @@ task :new_post, :title do |t, args|
|
|||
if File.exist?(filename)
|
||||
abort("rake aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'
|
||||
end
|
||||
category = get_stdin("Enter category name to group your post in (leave blank for none): ")
|
||||
tags = get_stdin("Enter tags to classify your post (comma separated): ")
|
||||
puts "Creating new post: #{filename}"
|
||||
open(filename, 'w') do |post|
|
||||
|
@ -32,6 +33,7 @@ task :new_post, :title do |t, args|
|
|||
post.puts "layout: post"
|
||||
post.puts "title: \"#{title.gsub(/&/,'&')}\""
|
||||
post.puts "modified: #{Time.now.strftime('%Y-%m-%d %H:%M:%S %z')}"
|
||||
post.puts "category: [#{category}]"
|
||||
post.puts "tags: [#{tags}]"
|
||||
post.puts "image:"
|
||||
post.puts " feature: "
|
||||
|
|
|
@ -40,23 +40,15 @@
|
|||
</div><!-- /#main -->
|
||||
|
||||
<div class="footer-wrap">
|
||||
{% if site.related_posts.size > 0 %}<div class="related-articles">
|
||||
<div class="related-articles">
|
||||
<h4>You might also enjoy <small class="pull-right">(<a href="{{ site.url }}/posts/">View all posts</a>)</small></h4>
|
||||
<ul>
|
||||
{% for post in site.related_posts limit:3 %}
|
||||
{% assign match = false %}
|
||||
{% for category in post.categories %}
|
||||
{% if page.categories contains category %}
|
||||
{% assign match = true %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if match %}
|
||||
<li><a href="{{ site.url }}{{ post.url }}" title="{{ post.title }}">{{ post.title }}</a></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<hr />
|
||||
</div><!-- /.related-articles -->{% endif %}
|
||||
</div><!-- /.related-articles -->
|
||||
<footer>
|
||||
{% include _footer.html %}
|
||||
</footer>
|
||||
|
|
|
@ -116,6 +116,7 @@ There are two rake tasks that can be used to create a new post or page with all
|
|||
rake new_post
|
||||
|
||||
Enter a title for your post: My Awesome Post
|
||||
Enter category name to group your post in (leave blank for none): blog
|
||||
Enter tags to classify your post (comma separated): web development, code
|
||||
Creating new post: _posts/2014-02-10-my-awesome-post.md
|
||||
{% endhighlight %}
|
||||
|
|
Loading…
Reference in a new issue