Sometimes wp:post_name can be empty (e.g. when a post is still draft), in this case we make up an appropriate permalink_title that will be used as the filename. The importer can always rename the file later on, and at least the file is unlikely to have been overwritten by another draft on the same day.

This commit is contained in:
Richard Jones 2011-06-28 02:31:42 -07:00
parent 365f57e8b3
commit 3389c6d508
1 changed files with 5 additions and 0 deletions

View File

@ -19,6 +19,11 @@ module Jekyll
(doc/:channel/:item).each do |item|
title = item.at(:title).inner_text.strip
permalink_title = item.at('wp:post_name').inner_text
# Fallback to "prettified" title if post_name is empty (can happen)
if permalink_title == ""
permalink_title = title.downcase.split.join('-')
end
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