diff --git a/apps/web/src/app/community/[boardCode]/PostCards.tsx b/apps/web/src/app/community/[boardCode]/PostCards.tsx index f9cc68b1..79761347 100644 --- a/apps/web/src/app/community/[boardCode]/PostCards.tsx +++ b/apps/web/src/app/community/[boardCode]/PostCards.tsx @@ -6,7 +6,6 @@ import { useRef } from "react"; import Image from "@/components/ui/FallbackImage"; import { IconPostLikeOutline } from "@/public/svgs"; import { IconCommunication } from "@/public/svgs/community"; -import { IconSolidConnentionLogo } from "@/public/svgs/mentor"; import type { ListPost } from "@/types/community"; import { normalizeImageUrlToUploadCdn } from "@/utils/cdnUrl"; import { convertISODateToDate } from "@/utils/datetimeUtils"; @@ -71,47 +70,77 @@ const PostCards = ({ posts, boardCode }: PostCardsProps) => { export default PostCards; -export const PostCard = ({ post, priorityImage = false }: { post: ListPost; priorityImage?: boolean }) => ( -
-
-
- {post.postCategory || ""} - {convertISODateToDate(post.createdAt) || "1970. 1. 1."} -
- {post.title || ""} -
- {post.content || "내용 없음"} -
-
-
- - {post.likeCount || 0} +const DEFAULT_THUMBNAIL_PATHS = new Set([ + "/article-thumb.png", + "/site-thumbnail.png", + "/images/article-thumb.png", + "/images/site-thumbnail.png", +]); + +const getThumbnailPathname = (thumbnailSrc: string) => { + try { + return new URL(thumbnailSrc, "https://solid-connection.local").pathname; + } catch { + return thumbnailSrc; + } +}; + +const getPostThumbnailSrc = (postThumbnailUrl: string | null) => { + const thumbnailSrc = normalizeImageUrlToUploadCdn(postThumbnailUrl); + const thumbnailPathname = getThumbnailPathname(thumbnailSrc); + + if ( + !thumbnailSrc || + DEFAULT_THUMBNAIL_PATHS.has(thumbnailPathname) || + thumbnailPathname.startsWith("/svgs/placeholders/") + ) { + return null; + } + + return thumbnailSrc; +}; + +export const PostCard = ({ post, priorityImage = false }: { post: ListPost; priorityImage?: boolean }) => { + const thumbnailSrc = getPostThumbnailSrc(post.postThumbnailUrl); + + return ( +
+
+
+ {post.postCategory || ""} + {convertISODateToDate(post.createdAt) || "1970. 1. 1."}
-
- - {post.commentCount || 0} + {post.title || ""} +
+ {post.content || "내용 없음"} +
+
+
+ + {post.likeCount || 0} +
+
+ + {post.commentCount || 0} +
-
-
-
- {post.postThumbnailUrl ? ( - 게시글 사진 - ) : ( -
- + {thumbnailSrc ? ( +
+
+ 게시글 사진
- )} -
+
+ ) : null}
-
-); + ); +};