Fix invalid ordering of posts published on the same day and move post_url specific comparison of posts where it belongs: Into post_url
This commit is contained in:
parent
ce8e1afba6
commit
87f6f8c971
|
@ -79,17 +79,12 @@ module Jekyll
|
||||||
|
|
||||||
# Compares Post objects. First compares the Post date. If the dates are
|
# Compares Post objects. First compares the Post date. If the dates are
|
||||||
# equal, it compares the Post slugs.
|
# 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.
|
# other - The other Post we are comparing to.
|
||||||
#
|
#
|
||||||
# Returns -1, 0, 1
|
# Returns -1, 0, 1
|
||||||
def <=>(other)
|
def <=>(other)
|
||||||
cmp = self.date.year <=> other.date.year
|
cmp = self.date <=> other.date
|
||||||
cmp = self.date.month <=> other.date.month if cmp == 0
|
|
||||||
cmp = self.date.day <=> other.date.day if cmp == 0
|
|
||||||
if 0 == cmp
|
if 0 == cmp
|
||||||
cmp = self.slug <=> other.slug
|
cmp = self.slug <=> other.slug
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,7 +23,7 @@ module Jekyll
|
||||||
site = context.registers[:site]
|
site = context.registers[:site]
|
||||||
|
|
||||||
site.posts.each do |p|
|
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
|
return p.url
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue