Added tag generation script

This commit is contained in:
Panos Sakkos 2015-10-07 23:34:03 +02:00
parent 9024728953
commit 4e776003a5
2 changed files with 35 additions and 5 deletions

24
scripts/generate-tags Executable file
View file

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