import { Post } from '@/types'; import Link from 'next/link'; import { format } from 'date-fns'; import { clsx } from 'clsx'; // ๐ŸŽจ ์Šคํƒ€์ผ ์กฐ๊ฑด๋ถ€ ์ ์šฉ์„ ์œ„ํ•ด clsx ์‚ฌ์šฉ // ๐Ÿ› ๏ธ ํ—ฌํผ ํ•จ์ˆ˜: ๋งˆํฌ๋‹ค์šด ๋ฌธ๋ฒ• ์ œ๊ฑฐํ•˜๊ณ  ์ˆœ์ˆ˜ ํ…์ŠคํŠธ๋งŒ ์ถ”์ถœ function getSummary(content?: string) { if (!content) return ''; return content .replace(/[#*`_~]/g, '') // ํŠน์ˆ˜๋ฌธ์ž(#, *, ` ๋“ฑ) ์ œ๊ฑฐ .replace(/\[(.*?)\]\(.*?\)/g, '$1') // ๋งํฌ์—์„œ ํ…์ŠคํŠธ๋งŒ ๋‚จ๊น€ [๊ธ€์ž](์ฃผ์†Œ) -> ๊ธ€์ž .replace(/\n/g, ' ') // ์ค„๋ฐ”๊ฟˆ์„ ๊ณต๋ฐฑ์œผ๋กœ .substring(0, 120); // 120์ž๊นŒ์ง€๋งŒ ์ž๋ฅด๊ธฐ } export default function PostCard({ post }: { post: Post }) { // ์š”์•ฝ๋ฌธ ์ƒ์„ฑ const summary = getSummary(post.content); // ๐Ÿ“ข ๊ณต์ง€ ์นดํ…Œ๊ณ ๋ฆฌ ์—ฌ๋ถ€ ํ™•์ธ (ํ•œ๊ธ€ '๊ณต์ง€' ๋˜๋Š” ์˜๋ฌธ 'Notice' ๋Œ€์†Œ๋ฌธ์ž ๋ฌด๊ด€) const isNotice = post.categoryName === '๊ณต์ง€' || post.categoryName.toLowerCase() === 'notice'; return (
{/* ์ƒ๋‹จ ์นดํ…Œ๊ณ ๋ฆฌ & ๋‚ ์งœ */}
{isNotice && '๐Ÿ“ข '}{post.categoryName}
{/* ์ œ๋ชฉ */}

{post.title}

{/* ์š”์•ฝ๊ธ€ */}

{summary}

{/* ํ•˜๋‹จ ์ •๋ณด */}
Read more โ†’
); }