<section>
  <div class="admin-header">
    <h1>Blog Posts</h1>
    <a class="button" href="/admin/posts/new">+ New Post</a>
  </div>
  <table class="admin-table">
    <thead>
      <tr><th>Title</th><th>Slug</th><th>Status</th><th>Updated</th><th></th></tr>
    </thead>
    <tbody>
      <% posts.forEach(function(post) { %>
        <tr>
          <td><%= post.title %></td>
          <td>/blog/<%= post.slug %></td>
          <td><%= post.status %></td>
          <td><%= post.updatedAt.toDateString() %></td>
          <td>
            <a href="/admin/posts/<%= post.id %>/edit">Edit</a>
            <form action="/admin/posts/<%= post.id %>?_method=DELETE" method="POST" style="display:inline"
                  onsubmit="return confirm('Delete this post?')">
              <button type="submit">Delete</button>
            </form>
          </td>
        </tr>
      <% }) %>
    </tbody>
  </table>
</section>
