feat : BBS 게시판을 백엔드 스크랩 게시물 API로 교체 (JWT 인증, 읽음 처리)
SpecialSource Frontend (React) CD / deploy (push) Successful in 13s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
headporterandClaude Opus 5.5 committed 2026-11-23 17:35:51 +09:00
1 parent cc814a484b
commit 4b10d4d3b2
11 files changed
+197 -85

No files matched your search

+47 -8
View File
@@ -1,24 +1,63 @@
import { POSTS } from "../mocks/posts";
import { useEffect } from "react";
import { markViewed } from "../api";
import type { ScrapedPost } from "../types";
import styles from "./bbs.module.css";
export default function PostDetail({ postId }: { postId: number }) {
const post = POSTS.find((p) => p.id === postId);
if (!post) return null;
// 외부 사이트 이미지는 Referer를 보고 차단하는 경우가 많음 → 안 보내기. 본문 링크는 새 탭으로
const prepare = (html: string) =>
html
.replaceAll("<img ", '<img referrerpolicy="no-referrer" loading="lazy" ')
.replaceAll("<a ", '<a target="_blank" rel="noreferrer" ');
export default function PostDetail({ post, token }: { post: ScrapedPost | undefined; token: string }) {
// 글을 열면 서버에 "읽음" 기록 → 스크랩 게시판에서 빠지고 "내가 읽은 글"로 이동
useEffect(() => {
if (post) markViewed(token, post.id).catch(() => {}); // 실패해도 읽기엔 지장 없음
}, [token, post]);
if (!post) {
return (
<section className={`${styles.win} ${styles.full}`}>
<div className={styles.dim}>글을 찾을 수 없습니다. &quot;L&quot;로 목록을 다시 불러오세요.</div>
</section>
);
}
return (
<section className={`${styles.win} ${styles.full}`}>
<span className={styles.cap}>═ 자유게시판 #{post.id} ═</span>
<span className={styles.cap}>
═ {post.siteName} {post.boardName} ═
</span>
<div className={styles.postHead}>
<span>제목 :</span> {post.title}
</div>
<div className={styles.postHead}>
<span>글쓴이:</span> {post.author} <span>날짜:</span> {post.date} <span>조회:</span> {post.views}
<span>글쓴이:</span> {post.author ?? "-"} <span>날짜:</span> {post.postedAt ?? "-"} <span>조회:</span>{" "}
{post.viewCount ?? "-"} <span>추천:</span> {post.likeCount ?? "-"}
</div>
<hr className={styles.rule} />
<div className={styles.body}>{post.body}</div>
{post.content ? (
// content는 백엔드에서 Jsoup Safelist로 script·이벤트 속성을 제거한 HTML이라 그대로 렌더링
<div className={styles.html} dangerouslySetInnerHTML={{ __html: prepare(post.content) }} />
) : post.imageUrls.length > 0 ? (
post.imageUrls.map((src, i) => (
<figure key={src} className={styles.figure}>
{/* eslint-disable-next-line @next/next/no-img-element -- 정적 export라 next/image 최적화 불가 */}
<img src={src} alt={`첨부 그림 ${i + 1}`} referrerPolicy="no-referrer" loading="lazy" />
<figcaption>
<span>[그림 {i + 1}]</span>
</figcaption>
</figure>
))
) : (
<div className={styles.dim}>본문을 가져오지 못했습니다. 원문에서 확인하세요.</div>
)}
<hr className={styles.rule} />
<div className={styles.footer}>
<b>L</b>=목록 · <b>M</b>=메인
<a className={styles.accent} href={post.link} target="_blank" rel="noreferrer">
원문 보기 ↗
</a>{" "}
· <b>L</b>=목록 · <b>M</b>=메인
</div>
</section>
);