Skip to content

Commit

Permalink
Return up to 10 ai_related_posts
Browse files Browse the repository at this point in the history
This matches what Jekyll returns in the built-in related_posts.
  • Loading branch information
mkasberg committed Apr 24, 2024
1 parent 51d2e0c commit 93e6e7e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## [Unreleased]

## [0.1.0] - 2024-04-18
- [Bugfix] Include up to 10 related posts (like native Jekyll does) instead of just 3.

## [0.1.1] - 2024-04-23

- [Bugfix] Exception when running in cache-only mode.

## [0.1.0] - 2024-04-23

- Initial release
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
jekyll_ai_related_posts (0.1.1)
jekyll_ai_related_posts (0.1.2)
activerecord (~> 7.0)
faraday (~> 2.9)
jekyll (>= 3.0)
Expand Down
2 changes: 1 addition & 1 deletion lib/jekyll_ai_related_posts/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def find_related(post)
relative_path: post.relative_path
} ]))
# The first result is the post itself, with a distance of 0.
rowids = results.sort_by { |r| r["distance"] }.drop(1).first(3).map { |r| r["rowid"] }
rowids = results.sort_by { |r| r["distance"] }.drop(1).first(10).map { |r| r["rowid"] }

posts_by_rowid = {}
rowids.each do |rowid|
Expand Down
2 changes: 1 addition & 1 deletion lib/jekyll_ai_related_posts/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module JekyllAiRelatedPosts
VERSION = "0.1.1"
VERSION = "0.1.2"
end

0 comments on commit 93e6e7e

Please sign in to comment.