From 87f6f8c971e1930fe37b82ffd76c19d57c4d485e Mon Sep 17 00:00:00 2001 From: Daniel Hilgarth Date: Sun, 3 Mar 2013 15:36:16 +0100 Subject: [PATCH] Fix invalid ordering of posts published on the same day and move post_url specific comparison of posts where it belongs: Into post_url --- lib/jekyll/post.rb | 7 +------ lib/jekyll/tags/post_url.rb | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index ab912d82..b8d0ad55 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -79,17 +79,12 @@ module Jekyll # 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 diff --git a/lib/jekyll/tags/post_url.rb b/lib/jekyll/tags/post_url.rb index ff4a29b8..008c12a2 100644 --- a/lib/jekyll/tags/post_url.rb +++ b/lib/jekyll/tags/post_url.rb @@ -23,7 +23,7 @@ module Jekyll 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