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