Refactor Post#related_posts to build the index in a different method
This commit is contained in:
parent
ffa93c22f1
commit
09c1c01d07
|
|
@ -229,6 +229,16 @@ module Jekyll
|
|||
return [] unless posts.size > 1
|
||||
|
||||
if self.site.lsi
|
||||
build_index
|
||||
|
||||
related = self.class.lsi.find_related(self.content, 11)
|
||||
related - [self]
|
||||
else
|
||||
(posts - [self])[0..9]
|
||||
end
|
||||
end
|
||||
|
||||
def build_index
|
||||
self.class.lsi ||= begin
|
||||
puts "Starting the classifier..."
|
||||
lsi = Classifier::LSI.new(:auto_rebuild => false)
|
||||
|
|
@ -239,12 +249,6 @@ module Jekyll
|
|||
puts ""
|
||||
lsi
|
||||
end
|
||||
|
||||
related = self.class.lsi.find_related(self.content, 11)
|
||||
related - [self]
|
||||
else
|
||||
(posts - [self])[0..9]
|
||||
end
|
||||
end
|
||||
|
||||
# Add any necessary layouts to this post.
|
||||
|
|
|
|||
Loading…
Reference in New Issue