From 0eb2796a66ba1d7fab243c34e55f285b9fbec766 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Thu, 11 Dec 2014 12:48:57 -0800 Subject: [PATCH] Sort static files just once. Ref: #2075. --- lib/jekyll/site.rb | 3 ++- lib/jekyll/static_file.rb | 8 +++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 7b8a4a00..3ddda474 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -187,6 +187,7 @@ module Jekyll end pages.sort_by!(&:name) + static_files.sort_by!(&:relative_path) end # Read all the files in //_posts and create a new Post @@ -384,7 +385,7 @@ module Jekyll "time" => time, "posts" => posts.sort { |a, b| b <=> a }, "pages" => pages, - "static_files" => static_files.sort { |a, b| a.relative_path <=> b.relative_path }, + "static_files" => static_files, "html_pages" => pages.select { |page| page.html? || page.url.end_with?("/") }, "categories" => post_attr_hash('categories'), "tags" => post_attr_hash('tags'), diff --git a/lib/jekyll/static_file.rb b/lib/jekyll/static_file.rb index 8e100656..02500b1d 100644 --- a/lib/jekyll/static_file.rb +++ b/lib/jekyll/static_file.rb @@ -3,6 +3,8 @@ module Jekyll # The cache of last modification times [path] -> mtime. @@mtimes = Hash.new + attr_reader :relative_path + # Initialize a new StaticFile. # # site - The Site. @@ -15,6 +17,7 @@ module Jekyll @dir = dir @name = name @collection = collection + @relative_path = File.join(*[@dir, @name].compact) end # Returns source file path. @@ -22,11 +25,6 @@ module Jekyll File.join(*[@base, @dir, @name].compact) end - # Returns the source file path relative to the site source - def relative_path - @relative_path ||= File.join(*[@dir, @name].compact) - end - def extname File.extname(path) end