From 715e0e550fc1f91375179be03e5a3dd9eaed3862 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Thu, 15 Feb 2024 00:41:56 +0800 Subject: [PATCH] :bug: Bug fixes of player --- src/pages/posts/[slug].astro | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/pages/posts/[slug].astro b/src/pages/posts/[slug].astro index 5fc9154..acca175 100644 --- a/src/pages/posts/[slug].astro +++ b/src/pages/posts/[slug].astro @@ -32,11 +32,14 @@ function getThumbnail(item: any): string | null { } function getAttachments(item: any): any[] { - if (item?.attachments[0] && item?.attachments[0].mimetype.startsWith("image")) { - return item?.attachments?.slice(1, item?.attachments?.length - 1) ?? []; - } else { - return item?.attachments; - } + let filtered = false; + return item.attachments.filter((item: any) => { + if(item.mimetype.startsWith("image") && !filtered) { + filtered = true; + return false; + } + return true; + }) } function getAuthorLink(user: any): string {