Skip to content
Browse files

Fix invalid ordering of posts published on the same day and move post…

…_url specific comparison of posts where it belongs: Into post_url
  • Loading branch information...
1 parent ce8e1af commit 87f6f8c971e1930fe37b82ffd76c19d57c4d485e @dhilgarth committed Mar 3, 2013
Showing with 2 additions and 7 deletions.
  1. +1 −6 lib/jekyll/post.rb
  2. +1 −1 lib/jekyll/tags/post_url.rb
View
7 lib/jekyll/post.rb
@@ -79,17 +79,12 @@ def read_yaml(base, name)
# Compares Post objects. First compares the Post date. If the dates are
# equal, it compares the Post slugs.
- # This comparison is used to create internal links using post_url.
- # Post filenames are without a time, but the date property in the YAML
- # front matter can be with time, so we compare only the date here.
#
# other - The other Post we are comparing to.
#
# Returns -1, 0, 1
def <=>(other)
- cmp = self.date.year <=> other.date.year
- cmp = self.date.month <=> other.date.month if cmp == 0
- cmp = self.date.day <=> other.date.day if cmp == 0
+ cmp = self.date <=> other.date
if 0 == cmp
cmp = self.slug <=> other.slug
end
View
2 lib/jekyll/tags/post_url.rb
@@ -23,7 +23,7 @@ def render(context)
site = context.registers[:site]
site.posts.each do |p|
- if p == @post
+ if p.slug == @post.slug and p.date.year == @post.date.year and p.date.month == @post.date.month and p.date.day == @post.date.day
return p.url
end
end

0 comments on commit 87f6f8c

Please sign in to comment.
Something went wrong with that request. Please try again.