feat: update tweet handling in PostDetailResponse and improve title generation logic
This commit is contained in:
parent
0d70401a8f
commit
0086c0142b
2 changed files with 13 additions and 1 deletions
|
|
@ -235,12 +235,24 @@ export default new Elysia({ prefix: "/post" })
|
|||
return status(404, "포스트를 찾을 수 없습니다.");
|
||||
}
|
||||
|
||||
const tweetData = typeof post.tweet === "object" && post.tweet !== null
|
||||
? post.tweet as {
|
||||
text?: string;
|
||||
title?: string;
|
||||
description?: string;
|
||||
}
|
||||
: undefined;
|
||||
|
||||
return {
|
||||
_id: post._id,
|
||||
type: post.type,
|
||||
url: post.tweet?.url,
|
||||
author: post.author,
|
||||
tags: Array.isArray(post.tags) ? post.tags : [],
|
||||
tweet: tweetData ? {
|
||||
text: tweetData.text ?? tweetData.description,
|
||||
title: tweetData.title,
|
||||
} : undefined,
|
||||
mediaUrl: post.mediaUrl,
|
||||
mediaIndex: post.mediaIndex,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ function createDetailDescription(post: PostDetailResponse) {
|
|||
function createDetailTitle(post: PostDetailResponse) {
|
||||
const author = post.author?.trim() || "unknown";
|
||||
const source = getSourceLabel(post.type);
|
||||
const rawText = post.type === "twitter" ? post.tweet?.text : post.tweet?.title;
|
||||
const rawText = post.tweet?.text || post.tweet?.title;
|
||||
const contentText = rawText?.trim() || post._id;
|
||||
return `${author} - ${contentText} | ${source}`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue