feat: display articles
This commit is contained in:
@@ -1,8 +1,26 @@
|
||||
import MarkdownIt from "markdown-it";
|
||||
const parser = new MarkdownIt();
|
||||
|
||||
export default function markdownToText(markdown: string): string {
|
||||
if(!markdown) return ''
|
||||
export function readDuration(markdown: string): number | undefined {
|
||||
const words = markdown.split(" ")?.filter(Boolean)?.length;
|
||||
return words && Math.round(words / 250);
|
||||
}
|
||||
|
||||
export function markdownToHtml(markdown: string): string {
|
||||
const md = new MarkdownIt({
|
||||
html: false, // set to true only if you trust the source
|
||||
linkify: true,
|
||||
typographer: true,
|
||||
breaks: true,
|
||||
});
|
||||
|
||||
// Convert -> sanitize
|
||||
const unsafeHtml = md.render(markdown);
|
||||
return unsafeHtml;
|
||||
}
|
||||
|
||||
export function markdownToText(markdown: string): string {
|
||||
if (!markdown) return "";
|
||||
return parser
|
||||
.render(markdown)
|
||||
.split("\n")
|
||||
Reference in New Issue
Block a user