PostEdit.html
HTML document, ASCII text
1<form> 2<input type="text" name="editing" id="BlogFileName"> 3<label for="BlogFileName">Blog post to edit.</label><br> 4<button>Edit</button><br> 5<em>Note: if none is selected, a new one will be created.</em> 6</form> 7 8<b id="NoPostFound" style="display:none">Cannot edit a non-existant post.</b> 9 10<form id="mainform" action="/DevHelp/.BlogBuilder" method="post"> 11<input type="text" name="title" placeholder="Insert title..."><br> 12<textarea name="Body"></textarea><br> 13<button>Post</button> 14</form> 15 16<script> 17const query = new URLSearchParams(location.search); 18var NewPost = !query.has("editing") || query.get("editing") == ""; 19 20if (!NewPost) { 21fetch(`/blog/${query.get("editing")}.md`) 22.then(res => { 23if (!res.ok) { 24NewPost = true; 25return ""; 26} 27return res.text() 28}) 29.then(res => { 30if (res == "") { 31document.querySelector("#mainform").style.display = "none"; 32document.querySelector("#NoPostFound").style.display = "block"; 33return; 34} 35 36}) 37} 38</script>