Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort pages by name by default #1848

Merged
merged 3 commits into from
Dec 19, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/jekyll/site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ def read_directories(dir = '')
static_files << StaticFile.new(self, self.source, dir, f)
end
end

pages.sort_by!(&:name)
end

# Read all the files in <source>/<dir>/_posts and create a new Post
Expand Down
7 changes: 7 additions & 0 deletions test/test_site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ def generate(site)
assert_equal @site.generators.sort_by(&:class).map{|g|g.class.priority}, @site.generators.map{|g|g.class.priority}
end

should "sort pages alphabetically" do
stub.proxy(Dir).entries { |entries| entries.reverse }
@site.process
sorted_pages = %w(.htaccess about.html bar.html contacts.html deal.with.dots.html foo.md index.html index.html sitemap.xml symlinked-file)
assert_equal sorted_pages, @site.pages.map(&:name)
end

should "read layouts" do
@site.read_layouts
assert_equal ["default", "simple", "post/simple"].sort, @site.layouts.keys.sort
Expand Down