% layout 'default';
% title my $thread_id = $thread->{'id'} ? "Thread #$thread_id" : '?';
<h2 class="page-title">
  <%= title %> <sup><%= link_to txt => url_for . '.txt' %></sup>
</h2>
<% if (keys %{$thread}) { =%>
<% content_for open_graph => begin %>
  <meta property="og:type" content="article">
  <meta property="og:title" content="<%= $thread->{'title'} %>">
  <meta property="og:description"
        content="<%= truncate_text $thread->{'body'} %>">
<% end %>
<% content_for twitter_card => begin %>
  <meta name="twitter:title" content="<%= $thread->{'title'} %>">
  <meta name="twitter:description"
        content="<%= truncate_text $thread->{'body'} %>">
<% end %>
<main class="pager">
  <article class="post">
    <h3 class="post__title">
      <%= $thread->{'title'} %>
      <span class="post__id">#<%= $thread->{'id'} %></span>
    </h3>
    <h4 class="post__date"><%= $thread->{'date'} %></h4>
    <h5 class="post__author"><%= $thread->{'author'} %></h5>
    <div class="post__body">
      <%== markdown $thread->{'body'} =%>
    </div>
    <nav class="post__nav">
      <%= link_to post_remark => {thread_id => $thread->{'id'}},
          (class => 'click'), begin %>
        Remark (<%= $thread->{'remark_tally'} %>)
      <% end %>
      <%= link_to bump_thread => {thread_id => $thread->{'id'}},
          (class => 'click'), begin %>
        Bump (<%= $thread->{'bump_tally'} %>)
      <% end %>
      <%= link_to Flag => flag_thread => {thread_id => $thread->{'id'}},
          (class => 'click') %>
    </nav>
  </article>
</main>
<% } =%>
<% if (keys %{$thread} && scalar @{$remarks}) { =%>
<section class="pager" id="remarks">
  <h3 class="pager__title">Remarks</h3>
  <% for my $remark (@{$remarks}) { =%>
  <article class="post">
    <h4 class="post__title">
      <span>
        <%= $remark->{'date'} %>
      </span>
      <%= link_to "#$remark->{'id'}", single_remark =>
          {remark_id => $remark->{'id'}}, (class => 'post__id') %>
    </h4>
    <h5 class="post__author"><%= $remark->{'author'} %></h5>
    <div class="post__body">
      <%== markdown $remark->{'body'} =%>
    </div>
    <nav class="post__nav">
      <%= link_to Remark => post_remark =>
          {thread_id => $thread->{'id'}, remark_id => $remark->{'id'}},
          (class => 'click') %>
      <%= link_to Flag => flag_remark => {remark_id => $remark->{'id'}},
          (class => 'click') %>
    </nav>
  </article>
  <% } =%>
  <% if ($last_page && $last_page != 1) { =%>
  <nav class="pager__nav">
    <%= pagination $this_page, $last_page, ($base_path . '/{page}#remarks') %>
  </nav>
  <% } =%>
</section>
<% } =%>