Skip to content

Instantly share code, notes, and snippets.

@yiyizym
Created February 3, 2017 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yiyizym/ce6021b89326079920dbef0c81c7bd18 to your computer and use it in GitHub Desktop.
Save yiyizym/ce6021b89326079920dbef0c81c7bd18 to your computer and use it in GitHub Desktop.
migrate from hexo to jekyll
# encoding: UTF-8
#!/usr/bin/env ruby
Dir.chdir('_posts') do
Dir.glob('*.markdown') do |filename|
File.open(filename, mode: 'r+:UTF-8') do |file|
content = file.read(file.size)
# date = content.match(/date: (\d+-\d+-\d+)/)
# if date.nil?
# puts filename
# else
# purename = filename.gsub(/^[\d-]+/,'')
# puts purename
# File.rename(filename, "#{date[1]}-#{purename}")
# end
# if content.start_with? '-'
# else
# file.rewind
# prepend_text = "---\nlayout: post\n"
# file.write (prepend_text + content).force_encoding("UTF-8")
# end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment