<h2 class="my-3">{{ page_title }}</h2>
<article class="container">
  <a href="{{ "admin/page/new/edit" | relative_link }}" class="btn btn-primary btn-sm mb-3">Create a New Page</a>
  <table class="table table-sm table-hover">
    <thead>
      <tr>
        <th scope="col">Title</th>
        <th scope="col">Permalink</th>
        <th scope="col">Last Updated</th>
      </tr>
    </thead>
    <tbody>
      {% for pg in pages -%}
        <tr>
          <td>
            {{ pg.title }}
            {%- if pg.is_default %} &nbsp; <span class="badge bg-success">HOME PAGE</span>{% endif -%}
            {%- if pg.show_in_page_list %} &nbsp; <span class="badge bg-primary">IN PAGE LIST</span> {% endif -%}<br>
            <small>
              {%- capture pg_link %}{% unless pg.is_default %}{{ pg.permalink }}{% endunless %}{% endcapture -%}
              <a href="{{ pg_link | relative_link }}" target="_blank">View Page</a>
              <span class="text-muted"> &bull; </span>
              <a href="{{ pg | edit_page_link }}">Edit</a>
              <span class="text-muted"> &bull; </span>
              {%- capture pg_del %}admin/page/{{ pg.id }}/delete{% endcapture -%}
              {%- capture pg_del_link %}{{ pg_del | relative_link }}{% endcapture -%}
              <a href="{{ pg_del_link }}" class="text-danger"
                 onclick="return Admin.deletePage('{{ pg.title }}', '{{ pg_del_link }}')">
                Delete
              </a>
            </small>
          </td>
          <td>/{% unless pg.is_default %}{{ pg.permalink }}{% endunless %}</td>
          <td>{{ pg.updated_on | date: "MMMM d, yyyy" }}</td>
        </tr>
      {%- endfor %}
    </tbody>
  </table>
  <form method="post" id="deleteForm">
    <input type="hidden" name="{{ csrf.form_field_name }}" value="{{ csrf.request_token }}">
  </form>
</article>
