From f8a4e00f89913b0c57ca016965f49efc26f4bff9 Mon Sep 17 00:00:00 2001 From: Dawid Rycerz Date: Tue, 13 Jan 2026 19:59:27 +0100 Subject: Make grid slightly better --- src/loaders/pleroma.ts | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/loaders/pleroma.ts b/src/loaders/pleroma.ts index 853c888..d633aa0 100644 --- a/src/loaders/pleroma.ts +++ b/src/loaders/pleroma.ts @@ -521,19 +521,37 @@ function cleanContent(htmlContent: string): string { */ function buildImageGridHtml(attachments: PleromaMediaAttachment[]): string { const imageAttachments = attachments.filter((attachment) => attachment.type === "image"); + const count = imageAttachments.length; - if (imageAttachments.length === 0) { + if (count === 0) { return ""; } - return ` -
-${imageAttachments - .map((attachment) => { + // Single image - no grid, full width + if (count === 1 && imageAttachments[0]) { + const attachment = imageAttachments[0]; const description = attachment.description || "Image"; - return `${description}`; - }) - .join("\n")} + return ` +
+${description} +
`; + } + + // 2+ images - use grid with max 2 columns + const isOdd = count % 2 !== 0; + const images = imageAttachments + .map((attachment, index) => { + const description = attachment.description || "Image"; + // For odd count, the last image spans all columns + const isLastImage = index === count - 1; + const spanClass = isOdd && isLastImage ? "sm:col-span-2" : ""; + return `${description}`; + }) + .join("\n"); + + return ` +
+${images}
`; } -- cgit v1.2.3