Module: Jekyll::Tagging::RelatedPosts
- Included in:
- Document
- Defined in:
- lib/jekyll/tagging/related_posts.rb,
lib/jekyll/tagging/related_posts/version.rb
Constant Summary collapse
- VERSION =
'1.3.1'
Class Method Summary collapse
-
.included(klass) ⇒ Object
Used to remove #related_posts so that it can be overridden.
Instance Method Summary collapse
-
#related_posts ⇒ Object
Calculate related posts.
Class Method Details
.included(klass) ⇒ Object
Used to remove #related_posts so that it can be overridden
7 8 9 10 11 |
# File 'lib/jekyll/tagging/related_posts.rb', line 7 def self.included(klass) klass.class_eval do remove_method :related_posts end end |
Instance Method Details
#related_posts ⇒ Object
Calculate related posts. Returns [<Post>]
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/jekyll/tagging/related_posts.rb', line 15 def return [] unless docs.count > 1 highest_freq = tag_freq.values.max = Hash.new(0) docs.each do |doc| doc.data["tags"].each do |tag| if self.data["tags"].include?(tag) && doc != self cat_freq = tag_freq[tag] [doc] += (1 + highest_freq - cat_freq) end end end () end |