<section class="sky-section">
  <div class="section-header">Similar Posts</div>
  <div class="grid grid-cols-[1fr,auto] bg-slate-100">
    <% factors = Domain::Factors::UserPostFavPostFactors.find_by(post: post) %>
    <% if factors %>
      <% neighbors = Domain::NeighborFinder.find_neighbors(factors).includes(:post).limit(10) %>
      <% num_neighbors = neighbors.size %>
      <% neighbors.each_with_index do |neighbor, index| %>
        <% border_classes = index < num_neighbors - 1 ? "border-b border-slate-300" : "" %>
        <% post = neighbor.post %>
        <% creator = post.class.has_creators? ? post.creator : nil %>
        <div class="text-md flex items-center px-4 py-1 <%= border_classes %>">
          <%= render "domain/has_description_html/inline_link_domain_post", post: post, visual_style: "sky-link" %>
        </div>
        <% if creator %>
          <div class="text-md items-center px-4 py-1 <%= border_classes %>">
            <%= render "domain/has_description_html/inline_link_domain_user", user: creator, visual_style: "sky-link", icon_size: "large" %>
          </div>
        <% else %>
          <div class="text-md truncate px-4 py-1 <%= border_classes %>">
            <%= post.primary_creator_name_fallback_for_view %>
          </div>
        <% end %>
      <% end %>
    <% else %>
      <div class="col-span-full p-4 text-center text-slate-500">No similar posts found</div>
    <% end %>
  </div>
</section>
