Fixes #132 (Commit from @bgoldman)

This commit is contained in:
Brandon Goldman 2016-02-22 18:32:53 -08:00 committed by Panos Sakkos
parent 85fdf5b510
commit 5b589baa73
9 changed files with 119 additions and 8 deletions

View file

@ -1,6 +1,6 @@
install
- Installs jekyll and the dependencies required by personal-jekyll-theme
serve-production
- Builds and serves your website in 127.0.0.1:4000
@ -10,6 +10,9 @@ serve
new-post <title>
- Creates a new post under \_posts
generate-category
- Generate all the categories that are used in the \_posts
generate-tag
- Generate all the tags that are used in the \_posts

26
scripts/generate-categories Executable file
View file

@ -0,0 +1,26 @@
#!/usr/bin/env ruby
require 'yaml'
POSTS_DIR = '_posts/'
CATEGORIES_DIR = 'categories/'
Dir.foreach(POSTS_DIR) do |post|
next if post == '.' or post == '..' or post == '.DS_Store'
postYaml = YAML.load_file(POSTS_DIR + post)
unless (postYaml['category'] == nil)
category = postYaml['category']
unless File.exist?(CATEGORIES_DIR + category.downcase + '.html')
puts('[+] Generating #' + category + ' page')
File.open(CATEGORIES_DIR + category.downcase + '.html', 'w') {|f| f.write(
"---\nlayout: category\nsection-type: category\ntitle: " + category + "\n---\n## Category")}
end
end
end