From 19cb2a244d21233fb3f289f8894f15e166ecec33 Mon Sep 17 00:00:00 2001 From: Mike Kasberg Date: Wed, 24 Apr 2024 08:38:55 -0600 Subject: [PATCH] Return up to 10 ai_related_posts This matches what Jekyll returns in the built-in related_posts. --- CHANGELOG.md | 8 +++++++- lib/jekyll_ai_related_posts/generator.rb | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df45983..5b307f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/jekyll_ai_related_posts/generator.rb b/lib/jekyll_ai_related_posts/generator.rb index baee6e8..d36428b 100644 --- a/lib/jekyll_ai_related_posts/generator.rb +++ b/lib/jekyll_ai_related_posts/generator.rb @@ -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|