Skip to content

Commit

Permalink
Added meta tag import goodness. This for instance allows you to prese…
Browse files Browse the repository at this point in the history
…rve all your hard-worked on WP SEO keywords, images, alternative images and other yummy-ness.

Replaced PubDate with wp:post_date, this is better than PubDate since some of the posts you import could be a draft (in this case the pubDate is invalid and contains a non-sensical value).
Added wp:status so we now know whether the post is published, draft or in the trash.
Added wp:post_type so we differentiate between posts and image or other post types
  • Loading branch information
richbecks committed Jun 28, 2011
1 parent e679729 commit 365f57e
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lib/jekyll/migrators/wordpressdotcom.rb
Expand Up @@ -4,6 +4,7 @@
require 'hpricot'
require 'fileutils'
require 'yaml'
require 'time'

module Jekyll
# This importer takes a wordpress.xml file, which can be exported from your
Expand All @@ -18,13 +19,26 @@ def self.process(filename = "wordpress.xml")
(doc/:channel/:item).each do |item|
title = item.at(:title).inner_text.strip
permalink_title = item.at('wp:post_name').inner_text
date = Time.parse(item.at(:pubDate).inner_text)
date = Time.parse(item.at('wp:post_date').inner_text)
status = item.at('wp:status').inner_text
type = item.at('wp:post_type').inner_text
tags = (item/:category).map{|c| c.inner_text}.reject{|c| c == 'Uncategorized'}.uniq

metas = Hash.new
item.search("wp:postmeta").each do |meta|
key = meta.at('wp:meta_key').inner_text
value = meta.at('wp:meta_value').inner_text
metas[key] = value;
end

name = "#{date.strftime('%Y-%m-%d')}-#{permalink_title}.html"
header = {
'layout' => 'post',
'title' => title,
'tags' => tags
'tags' => tags,
'status' => status,
'type' => type,
'meta' => metas
}

File.open("_posts/#{name}", "w") do |f|
Expand Down

0 comments on commit 365f57e

Please sign in to comment.