Order posts by slug name if the date is the same
This commit is contained in:
parent
d8d7ae3f0e
commit
8379958d95
|
@ -65,10 +65,12 @@ Feature: Site data
|
|||
And I have an "index.html" page that contains "{% for post in site.posts %}{{ post.title }}:{{ post.previous.title}},{{ post.next.title}} {% endfor %}"
|
||||
And I have the following posts:
|
||||
| title | date | content |
|
||||
| first | 2/26/2009 | first |
|
||||
| A | 3/26/2009 | A |
|
||||
| B | 3/26/2009 | B |
|
||||
| C | 3/26/2009 | C |
|
||||
| last | 4/26/2009 | last |
|
||||
When I run jekyll
|
||||
Then the _site directory should exist
|
||||
And I should see "C:B, B:A,C A:,B" in "_site/index.html"
|
||||
And I should see "last:C, C:B,last B:A,C A:first,B first:,A" in "_site/index.html"
|
||||
|
|
@ -70,11 +70,15 @@ module Jekyll
|
|||
end
|
||||
end
|
||||
|
||||
# Spaceship is based on Post#date
|
||||
# Spaceship is based on Post#date, slug
|
||||
#
|
||||
# Returns -1, 0, 1
|
||||
def <=>(other)
|
||||
self.date <=> other.date
|
||||
cmp = self.date <=> other.date
|
||||
if 0 == cmp
|
||||
cmp = self.slug <=> other.slug
|
||||
end
|
||||
return cmp
|
||||
end
|
||||
|
||||
# Extract information from the post filename
|
||||
|
|
Loading…
Reference in New Issue