Created
July 29, 2019 10:14
-
-
Save jackcallister/f993d34bc60ed8d2207538bb336e287e to your computer and use it in GitHub Desktop.
Rudimentary site compiler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'erb' | |
require 'tilt' | |
paths = Dir.glob('content/**/*').select{ |e| File.file? e } | |
paths.each do |path| | |
content = Tilt.new(path) | |
layout = Tilt.new('layouts/index.erb') | |
output = layout.render { content.render } | |
target = path.gsub(/content/, 'site').gsub(/.md/, '.html').gsub(/.html/, '/index.html') | |
File.write(path.gsub(/content/, 'site').gsub(/.md/, '.html'), output) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment