added article description field
This commit is contained in:
parent
91ae999d7f
commit
ccdd7ad589
@ -176,14 +176,14 @@
|
||||
<meta property="og:type" content="article">
|
||||
<meta property="og:locale" content="en_US">
|
||||
<meta property="og:site_name" content="HowFeed">
|
||||
<meta property="og:image" content={`https://howfeed.biz/a/${article.image}`}>
|
||||
<meta name="thumbnail" property="og:image" content={`https://howfeed.biz/a/${article.image}`}>
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<meta property="og:url" content={`https://howfeed.biz/a/${article.slug}`}>
|
||||
<meta property="article:published_time" content={new Date(article.created_at).toISOString()}>
|
||||
<meta name="pubdate" property="og:pubdate" content={new Date(article.created_at).toISOString()}>
|
||||
{#if article.updated_at}
|
||||
<meta property="article:modified_time" content={new Date(article.updated_at).toISOString()}>
|
||||
{/if}
|
||||
<meta property="article:author:first_name" content={article.author.realname.split(' ')[0]}>
|
||||
<meta property="article:author:last_name" content={article.author.realname.split(' ').slice(1)}>
|
||||
<meta property="article:section" content={article.category.name}>
|
||||
|
||||
<meta name="author" content={article.author.realname}>
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
let editor, form, uploadForm;
|
||||
let loading = false, loadingAttach = false;
|
||||
let title = '', category = '';
|
||||
let title = '', category = '', description = '';
|
||||
export let editArticle = undefined;
|
||||
export let categories;
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
result: function save() {
|
||||
window.localStorage['title'] = title;
|
||||
window.localStorage['category'] = category;
|
||||
window.localStorage['description'] = description;
|
||||
window.localStorage['html'] = editor.getHtml(true);
|
||||
alert('Successfully saved draft to browser local storage');
|
||||
}
|
||||
@ -59,6 +60,7 @@
|
||||
|
||||
onMount(function load() {
|
||||
title = editArticle ? editArticle.title : (window.localStorage['title'] || '');
|
||||
description = editArticle ? editArticle.description : (window.localStorage['description'] || '');
|
||||
category = editArticle ? editArticle.category.slug : (window.localStorage['category'] || '');
|
||||
editor.setHtml(editArticle ? editArticle.html : (window.localStorage['html'] || ''), false);
|
||||
});
|
||||
@ -167,8 +169,12 @@
|
||||
<div class="content">
|
||||
<a href="/cms">< Back to Dashboard</a>
|
||||
<h1>HowFeed Publisher</h1>
|
||||
{#if editArticle}
|
||||
<h3>Editing "{editArticle.title}"</h3>
|
||||
{/if}
|
||||
<form enctype="multipart/form-data" method="POST" action="/cms/article" bind:this={form}>
|
||||
<p>Article Title: <input type="text" name="title" bind:value={title} required placeholder="How to Assassinate the Governor of California"></p>
|
||||
<p>Article Description (optional): <input type="text" name="description" bind:value={description} placeholder="Sick of big government? Here's a helpful guide on how to stick it to the man!"></p>
|
||||
<p>Article Author: <strong>{$session.user.realname}</strong></p>
|
||||
<p>Article Category:
|
||||
{#if categories.length}
|
||||
@ -179,7 +185,12 @@
|
||||
</select>
|
||||
{/if}
|
||||
<button on:click|preventDefault={addCategory}>+</button></p>
|
||||
<p>Article Header Image: <input type="file" name="image" accept="image/*" required></p>
|
||||
<p>Article Header Image:
|
||||
<input type="file" name="image" accept="image/*" required={!editArticle}>
|
||||
{#if editArticle}
|
||||
(leave empty if you don't want to replace it)
|
||||
{/if}
|
||||
</p>
|
||||
</form>
|
||||
<Editor bind:this={editor} {actions} />
|
||||
<form enctype="multipart/form-data" action="/cms/upload" method="POST" bind:this={uploadForm}>
|
||||
|
@ -269,7 +269,7 @@ express()
|
||||
}
|
||||
}
|
||||
|
||||
const { html, title, category } = req.body;
|
||||
const { html, title, category, description } = req.body;
|
||||
const image = req.files && req.files.image;
|
||||
if (!title || (!editArticle && !image) || !html || !category) {
|
||||
res.writeHead(422, {
|
||||
@ -317,7 +317,7 @@ express()
|
||||
}
|
||||
if (editArticle) {
|
||||
let newObj = {
|
||||
html, title, category: cat, updated_at: Date.now()
|
||||
html, title, description, category: cat, updated_at: Date.now()
|
||||
};
|
||||
if (filename) {
|
||||
newObj.image = filename;
|
||||
@ -330,7 +330,7 @@ express()
|
||||
slug: editArticle.slug
|
||||
}));
|
||||
} else {
|
||||
const article = await new Article({ html, title, image: filename, category: cat, author: req.user._id });
|
||||
const article = await new Article({ html, title, image: filename, category: cat, description, author: req.user._id });
|
||||
await article.save();
|
||||
res.writeHead(200, {
|
||||
'Content-Type': 'application/json'
|
||||
|
Loading…
x
Reference in New Issue
Block a user