require 'redirect-to-filter' require 'version' module NanocRedirector module RedirectFrom def self.process(item, dest) return if item[:redirect_from].nil? return if dest.nil? redirect_hash = {} key = item.identifier.without_ext value = item[:redirect_from].is_a?(String) ? [item[:redirect_from]] : item[:redirect_from] redirect_hash[key] = value redirect_hash.values.each do |redirects| redirects.each do |redirect| content = NanocRedirector.redirect_template(dest) dir = "output/#{redirect}" unless File.directory?(dir) FileUtils.mkdir_p(dir) File.write("#{dir}/index.html", content) end end end end end def self.redirect_template(item_url) <<-EOF