<% content_for :title, @question.title.truncate(50) %>
<% content_for :description do %>
  <% Rails.cache.fetch "posts/#{@question.id}/description" do %>
    <%= @question.body_plain[0..74].strip %>...
    <%= @answers.any? ? @answers.first.body_plain[0..74].strip : '' %>
  <% end %>
<% end %>

<% content_for :twitter_card_meta do %>
  <meta name="twitter:card" content="summary" />
  <% if @question.user.twitter.present? %>
    <meta name="twitter:creator" content="@<%= @question.user.twitter %>" />
  <% end %>
  <meta property="og:url" content="<%= question_url(@question) %>" />
  <meta property="og:title" content="<%= @question.title %>" />
  <meta property="og:description" content="<%= @question.body_plain[0..150].strip %>..." />
  <meta property="og:image" content="<%= "https://#{RequestContext.community.host}#{SiteSetting['SiteLogoPath']}" %>" />
<% end %>

<%= render 'posts/expanded', post: @question %>

<h2><%= pluralize(@question.answers.where(deleted: false).count, "answer") %></h2>

<div class="button-list is-gutterless has-float-right">
  <a href="<%= query_url(sort: 'score') %>" class="button is-muted is-outlined <%= params[:sort].nil? || params[:sort] == 'score' ? 'is-active' : '' %>">Score</a>
  <a href="<%= query_url(sort: 'age') %>" class="button is-muted is-outlined <%= params[:sort] == 'age' ? 'is-active' : '' %>">Active</a>
</div>

<div class="has-clear-clear"></div>

<% @answers.each do |answer| %>
  <%= render 'posts/expanded', post: answer %>
<% end %>

<div class="text-center">
  <%= will_paginate @answers, renderer: BootstrapPagination::Rails %>
</div>

<% if user_signed_in? && !@question.closed %>
  <%= render 'answers/new', answer: Answer.new, parent: @question %>
<% elsif !@question.closed %>
  <p class="has-margin-top-4"></p>
  <%= link_to new_user_registration_path, class: 'button is-filled is-success h-m-t-4' do %>
    Sign up to answer this question &raquo;
  <% end %>
<% end %>
