From c18e0799c4b922cc3e2ecf0714207b43211a4ccb Mon Sep 17 00:00:00 2001 From: Mike Kasberg Date: Tue, 23 Apr 2024 13:19:39 -0600 Subject: [PATCH] Bugfix: indexed_posts is also used in fallback mode --- lib/jekyll_ai_related_posts/generator.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/jekyll_ai_related_posts/generator.rb b/lib/jekyll_ai_related_posts/generator.rb index 4ea2757..baee6e8 100644 --- a/lib/jekyll_ai_related_posts/generator.rb +++ b/lib/jekyll_ai_related_posts/generator.rb @@ -12,6 +12,11 @@ def generate(site) @site = site setup_database + @indexed_posts = {} + site.posts.docs.each do |p| + @indexed_posts[p.relative_path] = p + end + if fetch_enabled? Jekyll.logger.info "[ai_related_posts] Generating related posts..." @embeddings_fetcher = new_fetcher @@ -20,11 +25,6 @@ def generate(site) ensure_embedding_cached(p) end - @indexed_posts = {} - site.posts.docs.each do |p| - @indexed_posts[p.relative_path] = p - end - @site.posts.docs.each do |p| find_related(p) end