diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 6a9ba402133..2a4975a9687 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -137,7 +137,7 @@ def generated_path "month" => date.strftime("%m"), "day" => date.strftime("%d"), "title" => slug, - "categories" => categories.sort.join('/') + "categories" => categories.join('/') }.inject(template) { |result, token| result.gsub(/:#{token.first}/, token.last) }.gsub("//", "/") diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 78c2bb6cc1b..eb8cbcb595e 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -123,6 +123,8 @@ def textile(content) def process self.reset self.read_layouts + self.recurse_handle_posts + self.coordinate_posts self.transform_pages self.transform_sass if self.sass self.write_posts @@ -154,6 +156,7 @@ def read_posts(dir) # first pass processes, but does not yet render post content entries.each do |f| + print "Creating from dir: ", dir, " the post ", f, "\n" if Post.valid?(f) post = Post.new(self, self.source, dir, f) @@ -164,7 +167,9 @@ def read_posts(dir) end end end + end + def coordinate_posts() self.posts.sort! # second pass renders each post now that full site payload is available @@ -188,6 +193,24 @@ def write_posts end end + def recurse_handle_posts(dir = '') + base = File.join(self.source, dir) + entries = filter_entries(Dir.entries(base)) + directories = entries.select { |e| File.directory?(File.join(base, e)) } + + # we need to make sure to process _posts *first* otherwise they + # might not be available yet to other templates as {{ site.posts }} + if directories.include?('_posts') + FileUtils.mkdir_p(File.join(self.dest, dir)) + read_posts(dir) + end + directories.each do |newDir| + if File.directory?(File.join(base, newDir)) + next if self.dest.sub(/\/$/, '') == File.join(base, newDir) + recurse_handle_posts(File.join(dir, newDir)) + end + end + end # Copy all regular files from to / ignoring # any files/directories that are hidden or backup files (start # with "." or "#" or end with "~") or contain site content (start with "_") @@ -203,11 +226,10 @@ def transform_pages(dir = '') directories = entries.select { |e| File.directory?(File.join(base, e)) } files = entries.reject { |e| File.directory?(File.join(base, e)) } - # we need to make sure to process _posts *first* otherwise they - # might not be available yet to other templates as {{ site.posts }} + # we need to remove _posts here, they were previously processed by + # recurse_handle_posts if directories.include?('_posts') directories.delete('_posts') - read_posts(dir) end [directories, files].each do |entries| entries.each do |f|