fixed article content not being sent by publisher

This commit is contained in:
James Shiffer 2020-06-12 02:12:19 -07:00
parent c0214eef58
commit 90724027af

View File

@ -9,13 +9,13 @@
</script> </script>
<script> <script>
import { stores } from '@sapper/app'; import { stores, goto } from '@sapper/app';
import Editor from 'cl-editor/src/Editor.svelte'; import Editor from 'cl-editor/src/Editor.svelte';
const { session } = stores(); const { session } = stores();
let editor, form; let editor;
let html; let title = '', image = '';
let actions = [ let actions = [
'viewHtml', 'undo', 'redo', 'b', 'i', 'u', 'strike', 'sup', 'sub', 'h1', 'h2', 'p', 'blockquote', 'viewHtml', 'undo', 'redo', 'b', 'i', 'u', 'strike', 'sup', 'sub', 'h1', 'h2', 'p', 'blockquote',
@ -40,8 +40,17 @@
async function submit() async function submit()
{ {
html = editor.getHtml(true); let html = editor.getHtml(true);
form.submit(); const res = await fetch(`/cms/article`, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({ html, image, title })
});
const json = await res.json();
goto(`/a/${json.slug}`);
} }
</script> </script>
@ -58,11 +67,10 @@
<div class="content"> <div class="content">
<a href="/cms">&lt; Back to Dashboard</a> <a href="/cms">&lt; Back to Dashboard</a>
<h1>HowFeed Publisher</h1> <h1>HowFeed Publisher</h1>
<form method="POST" action="/cms/article" bind:this={form}> <form method="POST" action="/cms/article">
<input type="hidden" name="html" value={html}> <p>Article Title: <input type="text" name="title" bind:value={title} required placeholder="How to Assassinate the Governor of California"></p>
<p>Article Title: <input type="text" name="title" required placeholder="How to Assassinate the Governor of California"></p>
<p>Article Author: <strong>{$session.user.realname}</strong></p> <p>Article Author: <strong>{$session.user.realname}</strong></p>
<p>Article Header Image URL: <input type="text" name="image" required placeholder="http:// ..."></p> <p>Article Header Image URL: <input type="text" name="image" bind:value={image} required placeholder="http:// ..."></p>
</form> </form>
<Editor bind:this={editor} {actions} /> <Editor bind:this={editor} {actions} />
<button on:click={submit}>Submit</button> <button on:click={submit}>Submit</button>