Created
November 30, 2014 02:32
-
-
Save topher6345/e497efed7f4d1a39b48f to your computer and use it in GitHub Desktop.
Inline CSS in Built Jekyll Project.
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
Dir[File.join('_site', '**', '*')].reject { |p| File.directory? p } | |
.reject { |filename| !filename[/\.html/] } | |
.each do |file| | |
main_css = File.read('_site/css/main.css') | |
old_contents = File.read(file) | |
new_contents = old_contents.gsub( | |
"<link href='css/main.css' rel='stylesheet'>", | |
"<style>#{main_css}</style>" | |
) | |
File.open(file, 'w') { |newfile| newfile.write(new_contents) } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment