<% page_title "Related tags" %>
<%= render "tags/secondary_links" %>

<div id="c-related-tags">
  <div id="a-show">
    <h1>Related tags</h1>

    <%= search_form_for(related_tag_path) do |f| %>
      <%= f.input :query, label: "Tag", input_html: { value: params[:search][:query], "data-autocomplete": "tag" } %>
      <%= f.input :category, collection: TagCategory.categories.map(&:capitalize), include_blank: true, selected: params[:search][:category] %>
      <%= f.submit "Show" %>
    <% end %>

    <% if params.dig(:search, :query).present? %>
      <%= table_for @query.tags do |t| %>
        <% t.column "Name" do |tag| %>
          <%= link_to_wiki "?", tag.name, class: tag_class(tag) %>
          <%= link_to tag.name, posts_path(tags: tag.name), class: tag_class(tag) %>
        <% end %>
      <% end %>
    <% end %>
  </div>
</div>
