Latest post is chosen first in related posts
This commit is contained in:
parent
c688ee67b6
commit
dfca2c6edc
|
@ -46,7 +46,8 @@ module Jekyll
|
||||||
end
|
end
|
||||||
|
|
||||||
def most_recent_posts
|
def most_recent_posts
|
||||||
(self.site.posts - [self.post])[0..9]
|
recent_posts = self.site.posts.reverse - [self.post]
|
||||||
|
recent_posts.first(10)
|
||||||
end
|
end
|
||||||
|
|
||||||
def display(output)
|
def display(output)
|
||||||
|
|
|
@ -13,7 +13,12 @@ class TestRelatedPosts < Test::Unit::TestCase
|
||||||
should "use the most recent posts for related posts" do
|
should "use the most recent posts for related posts" do
|
||||||
@site.reset
|
@site.reset
|
||||||
@site.read
|
@site.read
|
||||||
assert_equal @site.posts[0..9], Jekyll::RelatedPosts.new(@site.posts.last).build
|
|
||||||
|
last_post = @site.posts.last
|
||||||
|
related_posts = Jekyll::RelatedPosts.new(last_post).build
|
||||||
|
|
||||||
|
last_10_recent_posts = (@site.posts.reverse - [last_post]).first(10)
|
||||||
|
assert_equal last_10_recent_posts, related_posts
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue