Created
December 10, 2016 11:44
-
-
Save lbain/5ce9ef81f6a3ce6f3b4b84774f9a63d8 to your computer and use it in GitHub Desktop.
With the middleman v4 upgrade it is now required that filenames have fully qualified file extensions. For the most part, this means they need .html added after the filename before the rest of the extensions. This gist will help with the renaming process.
This file contains 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
path_to_project = "" # FILL ME IN | |
# Step 1: get a list of all the extensions you use | |
require 'set' | |
extensions = Set.new [] | |
Dir.glob(path_to_project).each do |file| | |
parts = file.split('.') | |
extensions.merge(parts[1.. parts.length]) | |
end | |
extensions.each do |extension| | |
puts extension | |
end | |
# Step 2: convert the extensions you want converted | |
extensions_to_convert = [] # FILL ME IN | |
Dir.glob(path_to_project).each do |file| | |
parts = file.split('.') | |
should_convert_extension? = (parts & extensions_to_convert).any? | |
already_converted? = parts.include? 'html' | |
next unless should_convert_extension? and not already_converted? | |
new_name = parts[0] + '.html.' + parts[1..parts.length].join('.') | |
# verify file conversion | |
puts "#{file} > #{new_name}" | |
# uncomment to make actual changes | |
# File.rename(file, new_name) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment