From 5606bf665cafa163f1f7593ec2309366f812c759 Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Fri, 29 Apr 2022 16:40:36 -0400 Subject: [PATCH] Truncate image preview to 120 chars --- og-image/api/_lib/template.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/og-image/api/_lib/template.ts b/og-image/api/_lib/template.ts index 73105f6b..79d8e2b6 100644 --- a/og-image/api/_lib/template.ts +++ b/og-image/api/_lib/template.ts @@ -85,7 +85,6 @@ export function getHtml(parsedReq: ParsedRequest) { const { theme, fontSize, - question, probability, metadata, @@ -93,6 +92,10 @@ export function getHtml(parsedReq: ParsedRequest) { creatorUsername, creatorAvatarUrl, } = parsedReq + const MAX_QUESTION_CHARS = 120 + const truncatedQuestion = question.length > MAX_QUESTION_CHARS + ? question.slice(0, MAX_QUESTION_CHARS) + '...' + : question const hideAvatar = creatorAvatarUrl ? '' : 'hidden' return ` @@ -141,7 +144,7 @@ export function getHtml(parsedReq: ParsedRequest) {
- ${question} + ${truncatedQuestion}
${probability}