jekyll-to-wordpress/finalize_export.rb

15 lines
595 B
Ruby
Raw Normal View History

2020-12-08 18:37:51 +00:00
data = STDIN.read
# Replace the image paths to be accessible in Wordpress.
# The new path given here is the path for my case: A multi-site blog. The 1970/01
# in the path was determined by setting a date during extract_media.rb.
# Upload a file to your media gallery and look at the image url to determine
# your correct path.
images = data.scan(/(?:src|href)="(\/uploads\/.+?)"/).to_a.map(&:first).uniq
images.each do |path|
data = data.gsub("="#{path}"", "="/wp-content/uploads/sites/5/1970/01/#{File.basename(path)}"")
end
puts data.gsub(/([^>])\n/, "\\1 ")