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 19cb2a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 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.2.0] - 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 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

0 comments on commit 19cb2a2

Please sign in to comment.