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

18
server/utils/truncate.js Normal file
View File

@ -0,0 +1,18 @@
import truncate from 'truncate-html';
import marked from 'marked';
truncate.defaultOptions = {
stripTags: false,
ellipsis: '...',
decodeEntities: false,
excludes: ['h1', 'pre',],
};
const truncateMarkdown = (text, length) => {
const html = marked(text);
return truncate(html, length);
};
export {
truncateMarkdown
};