Created
February 3, 2017 06:37
-
-
Save yiyizym/ce6021b89326079920dbef0c81c7bd18 to your computer and use it in GitHub Desktop.
migrate from hexo to jekyll
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
# 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