{% extends 'base.html' %}

{% block header %}
	<h1>{% block title %}
		{% if post is not none %}
			Edit "{{ post['title'] }}"
		{% else %}
			New Post
		{% endif %}
	{% endblock %}</h1>
{% endblock %}

{% block nav %}
<li><a href="{{ url_for('index') }}" class="button">Back to index</a>
{% endblock %}

{% block content %}
	<form method="POST">
		<label for="title">Title</label>
		<input name="title" id="title" value="{{ request.form['title'] or post['title'] }}" required>
		<label for="body">Body</label>
		<textarea name="body" id="body">{{ request.form['body'] or post['body'] }}</textarea>
		<input type="submit" value="Save">
	</form>
	{% if post is not none %}
		<hr>
		<form action="{{ url_for('blog.delete', post_id=post['id']) }}" method="POST">
			<input class="danger" type="submit" value="Delete" onclick="return confirm('Are you sure?');">
		</form>
	{% endif %}
{% endblock %}
