18 lines
379 B
JavaScript
18 lines
379 B
JavaScript
import truncate from 'truncate-html';
|
|
import { convertToMarkdown } from '../../src/utils/markdown';
|
|
|
|
truncate.defaultOptions = {
|
|
stripTags: false,
|
|
ellipsis: '...',
|
|
decodeEntities: false,
|
|
excludes: ['h1', 'pre', ],
|
|
};
|
|
|
|
const truncateMarkdown = (text, length) => {
|
|
const html = convertToMarkdown(text);
|
|
return truncate(html, length);
|
|
};
|
|
|
|
export {
|
|
truncateMarkdown,
|
|
}; |