From 93e6e7ed08bcbd1e900c7ceb97ab3961a3c4d997 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 +++++++- Gemfile.lock | 2 +- lib/jekyll_ai_related_posts/generator.rb | 2 +- lib/jekyll_ai_related_posts/version.rb | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df45983..96cd5bd 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.1.1] - 2024-04-23 + +- [Bugfix] Exception when running in cache-only mode. + +## [0.1.0] - 2024-04-23 - Initial release diff --git a/Gemfile.lock b/Gemfile.lock index af1ddd5..60cd03a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) 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| diff --git a/lib/jekyll_ai_related_posts/version.rb b/lib/jekyll_ai_related_posts/version.rb index 55d0028..57f6a0a 100644 --- a/lib/jekyll_ai_related_posts/version.rb +++ b/lib/jekyll_ai_related_posts/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module JekyllAiRelatedPosts - VERSION = "0.1.1" + VERSION = "0.1.2" end