<html>
<head>
    <title>Record your knowledge</title>
    <%- include('header.ejs') %>
</head>

<body>
<div id="mainpanel">
<h1>Tell the people about dragons:</h1>

<% if(draft._id) { %>
<form action="/blog/<%=draft._id%>/edit" method="POST">
<% } else { %>
<form action="/blog/writepost" method="POST">
<% } %>

 
<input id="title" name="title" type="text"/><br/>

<textarea name="body" style="width: 100%; height:500px">
<% if(draft.body) { %><%= draft.body %><% } %>
</textarea><br/>

<% if(draft.title) { %>
<button type="submit">Update!</button>
<% } else { %>
<button type="submit">Post!</button>
<% } %>
</form>
</div>
<%- include('navbar.ejs') %>

<script>

var title= "<%=draft.title%>";

$(()=>{
    if(title!="") $('#title').val(title);
})
</script>
</body>

</html>
