Update generate-tags

Fixed bug when posts do not have tags. Script will now happily run as long as the tags field is present in the yaml preamble.
This commit is contained in:
Jørn Ølmheim 2016-02-09 12:30:10 +01:00
parent cff5b23c0f
commit 2dc41ae527

View file

@ -9,16 +9,18 @@ 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 (postYaml['tags'] == nil)
postYaml['tags'].each{|tag|
unless File.exist?(TAGS_DIR + tag + '.html')
unless File.exist?(TAGS_DIR + tag + '.html')
puts('[+] Generating #' + tag + ' page')
puts('[+] Generating #' + tag + ' page')
File.open(TAGS_DIR + tag + '.html', 'w') {|f| f.write(
"---\nlayout: tag\nsection-type: tag\ntitle: " + tag + "\n---\n## Tag")}
File.open(TAGS_DIR + tag + '.html', 'w') {|f| f.write(
"---\nlayout: tag\nsection-type: tag\ntitle: " + tag + "\n---\n## Tag")}
end
}
end
}
end
end