{% extends "admin/base.html" %}

{% block title %}{{ "Edit" if page else "New" }} Page - Admin - {{ site_name() }}{% endblock %}

{% block admin_content %}
<hgroup>
    <h1>{{ "Edit" if page else "New" }} Page</h1>
    <p>{{ "Update page details" if page else "Create a new page" }}</p>
</hgroup>

<form method="post" action="{{ '/admin/pages/' ~ page.id ~ '/edit' if page else '/admin/pages/new' }}">
    <label for="title">Title</label>
    <input type="text" id="title" name="title" value="{{ page.title if page else '' }}" required>

    <label for="slug">Slug</label>
    <input type="text" id="slug" name="slug" value="{{ page.slug if page else '' }}" required placeholder="e.g., about or services/consulting">
    <small class="text-muted">The URL path for this page (e.g., "about" becomes /about)</small>

    <label for="content">Content</label>
    <textarea id="content" name="content" rows="15">{{ page.content if page else '' }}</textarea>

    <label>
        <input type="checkbox" name="is_published" {% if page and page.is_published %}checked{% endif %}>
        Published
    </label>

    <div class="form-actions">
        <button type="submit">{{ "Update" if page else "Create" }} Page</button>
        <a href="/admin/pages" role="button" class="outline">Cancel</a>
    </div>
</form>
{% endblock %}
