refactors index building script to output JSON

also removes index.md
This commit is contained in:
Leandro Ostera
2015-03-04 21:10:08 -03:00
parent 21cb9ac9e1
commit e24d9800a8
4 changed files with 27 additions and 190 deletions

25
scripts/build_index.rb Executable file
View File

@@ -0,0 +1,25 @@
#!/usr/bin/env ruby
require "json"
commands = {}
Dir["#{ENV["TLDRHOME"]}/pages/**/*.md"].each do |file|
# "./pages/osx/xsltproc.md",
file = file.split("/")
name = file.pop().gsub(".md","")
platform = file.pop()
unless commands.key?(name)
commands[name] = {
name: name,
platform: [platform]
}
else
commands[name][:platform] << platform
end
end
commands = commands.map do |k,v| v end
File.write("#{ENV["TLDRHOME"]}/pages/index.json", {commands: commands}.to_json)