From 0ca385deaf00d905081c66d0e0164558531e0e70 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 3 Apr 2020 13:46:25 -0400 Subject: Adding a text body preview and icon for posts with a body. Fixes #617 --- ui/src/utils.ts | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'ui/src/utils.ts') diff --git a/ui/src/utils.ts b/ui/src/utils.ts index 8ecef19b..d659509c 100644 --- a/ui/src/utils.ts +++ b/ui/src/utils.ts @@ -823,3 +823,11 @@ function hsl(num: number) { function randomHsl() { return `hsla(${Math.random() * 360}, 100%, 50%, 1)`; } + +export function previewLines(text: string, lines: number = 3): string { + // Use lines * 2 because markdown requires 2 lines + return text + .split('\n') + .slice(0, lines * 2) + .join('\n'); +} -- cgit v1.2.3