Added document previews and fixed saving

This commit is contained in:
Jori Lallo
2016-05-22 14:31:21 -07:00
parent b840b300b5
commit 0beeeb9582
4 changed files with 25 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
import marked from 'marked';
import { truncateMarkdown } from './utils/truncate';
import Document from './models/Document';
@@ -45,7 +46,7 @@ export function presentAtlas(atlas, includeRecentDocuments=false) {
let recentDocuments = [];
await Promise.all(documents.map(async (document) => {
recentDocuments.push(await presentDocument(document));
recentDocuments.push(await presentDocument(document, true));
}))
data.recentDocuments = recentDocuments;
}
@@ -60,6 +61,7 @@ export async function presentDocument(document, includeAtlas=false) {
title: document.title,
text: document.text,
html: marked(document.text),
preview: truncateMarkdown(document.text, 160),
createdAt: document.createdAt,
updatedAt: document.updatedAt,
atlas: document.atlaId,