lib/jekyll/post.rb in mojombo-jekyll-0.1.3 vs lib/jekyll/post.rb in mojombo-jekyll-0.1.4
- old
+ new
@@ -53,17 +53,31 @@
self.slug = slug
self.ext = ext
end
# The generated directory into which the post will be placed
- # upon generation. e.g. "/2008/11/05/"
+ # upon generation. This is derived from the permalink or, if
+ # permalink is absent, set to the default date
+ # e.g. "/2008/11/05/"
#
# Returns <String>
def dir
- self.date.strftime("/%Y/%m/%d/")
+ permalink ?
+ permalink.to_s.split("/")[0..-2].join("/") :
+ date.strftime("/%Y/%m/%d/")
end
+ # The full path and filename of the post.
+ # Defined in the YAML of the post body
+ # (Optional)
+ #
+ # Returns <String>
+ def permalink
+ self.data && self.data['permalink']
+ end
+
+
# The generated relative url of this post
# e.g. /2008/11/05/my-awesome-post.html
#
# Returns <String>
def url
@@ -109,10 +123,10 @@
# Write the generated post file to the destination directory.
# +dest+ is the String path to the destination dir
#
# Returns nothing
def write(dest)
- FileUtils.mkdir_p(File.join(dest, self.dir))
+ FileUtils.mkdir_p(File.join(dest, dir))
path = File.join(dest, self.url)
File.open(path, 'w') do |f|
f.write(self.output)
end
\ No newline at end of file