summaryrefslogtreecommitdiffstats
path: root/ui/src/utils.ts
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-04-03 13:46:25 -0400
committerDessalines <tyhou13@gmx.com>2020-04-03 13:46:25 -0400
commit0ca385deaf00d905081c66d0e0164558531e0e70 (patch)
tree8521f8f9a571fa644bc940abaa84a61faf539aa8 /ui/src/utils.ts
parenta497a568db6349b25f7b662079141f8a3ddfb6cd (diff)
Adding a text body preview and icon for posts with a body. Fixes #617
Diffstat (limited to 'ui/src/utils.ts')
-rw-r--r--ui/src/utils.ts8
1 files changed, 8 insertions, 0 deletions
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');
+}