Moving comparison for PostUrl tag to the PostComparer class

This commit is contained in:
Parker Moore 2013-04-22 12:57:52 +02:00
parent ba64a9fe30
commit 24aabbe05f
1 changed files with 8 additions and 5 deletions

View File

@ -10,6 +10,13 @@ module Jekyll
@slug = slug
@date = Time.parse(date)
end
def ==(other)
slug == other.slug &&
date.year == other.date.year &&
date.month == other.date.month &&
date.day == other.date.day
end
end
class PostUrl < Liquid::Tag
@ -23,11 +30,7 @@ module Jekyll
site = context.registers[:site]
site.posts.each do |p|
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
if @post == p
return p.url
end
end