Skip to content

Commit 9d42804

Browse files
fix: 글에 이미지 없는 경우 시리즈 썸네일을 fallback으로 사용하도록 변경
1 parent d8582b3 commit 9d42804

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

app/api/posts/[slug]/route.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,17 @@ export async function PUT(
4747
const body = await req.json();
4848
const post = await Post.findOne({ slug: params.slug });
4949

50+
let thumbnailOfPost = getThumbnailInMarkdown(body.content);
51+
if (!thumbnailOfPost) {
52+
const seriesThumbnail = await Series.findById(body.seriesId).select('thumbnailImage');
53+
thumbnailOfPost =
54+
seriesThumbnail?.thumbnailImage ||
55+
'/images/placeholder/thumbnail_example2.webp';
56+
}
57+
5058
const updatedPost = await Post.findOneAndUpdate(
5159
{ slug: params.slug },
52-
{ ...body, thumbnailImage: getThumbnailInMarkdown(body.content) },
60+
{ ...body, thumbnailImage: thumbnailOfPost },
5361
{
5462
new: true,
5563
runValidators: true,

0 commit comments

Comments
 (0)