fix: 목록·검색 카드에서 백틱을 지운다
카드는 본문 요약을 그대로 가져다 세 줄로 자른다. 그 요약은 Markdown 으로 쓰였으므로 작성자가 코드 표시로 쓴 백틱이 카드에도 그대로 나왔다 — 문서 본문에서는 <code> 가 되지만 카드에서는 그냥 문자다. 홈·탐색·검색이 같은 텍스트를 쓰므로 세 곳에서 같이 보였다. 배포된 검색 모달을 열어 보고서야 알았다: 본문만 고치고 카드는 그대로 두었다. 카드에서 코드 스타일을 살리지 않는 이유는 카드가 훑어보는 자리이기 때문이다. 한 줄 안에 배경색 조각이 여럿 끼면 제목보다 그쪽이 먼저 눈에 든다. 문단 줄바꿈도 공백으로 접는다 — 어차피 세 줄에서 잘리므로 줄을 지켜 봐야 잘리는 위치만 어긋난다. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011nAjrqNHGPNngN4aUbcyvJ
This commit is contained in:
co-authored by
Claude Opus 5
parent
833943a286
commit
795a4bf4a9
@@ -9,6 +9,7 @@ import {
|
||||
moveFocus,
|
||||
shouldNormalizeFocusUrl,
|
||||
} from "../../../domain/public/focus-state.ts";
|
||||
import { cardSummary } from "../../shared/card-summary.ts";
|
||||
|
||||
type HomeFocusProps = {
|
||||
items: ReadonlyArray<HomeFocusItem>;
|
||||
@@ -122,7 +123,7 @@ export function HomeFocus({
|
||||
>
|
||||
<div className="focus-summary">
|
||||
<h2>{item.title}</h2>
|
||||
<p>{item.summary}</p>
|
||||
<p>{cardSummary(item.summary)}</p>
|
||||
<Link className="text-link" to={item.targetPath}>
|
||||
작업 맥락 보기 <span aria-hidden="true">↗</span>
|
||||
</Link>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Link } from "react-router-dom";
|
||||
import { cardSummary } from "../../shared/card-summary.ts";
|
||||
|
||||
export type LatestEntry = {
|
||||
id: string;
|
||||
@@ -55,7 +56,7 @@ export function LatestIndex({
|
||||
</div>
|
||||
<div className="latest-copy">
|
||||
<h3>{entry.title}</h3>
|
||||
<p>{entry.summary}</p>
|
||||
<p>{cardSummary(entry.summary)}</p>
|
||||
<p className="latest-mobile-meta">
|
||||
{entry.topic} · {entry.project}
|
||||
</p>
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Link } from "react-router-dom";
|
||||
|
||||
import type { PublicRecord } from "../../../application/ports/public-content-queries.ts";
|
||||
import { DOCUMENT_KIND_LABELS } from "../../shared/document-kind-labels.ts";
|
||||
import { cardSummary } from "../../shared/card-summary.ts";
|
||||
|
||||
export function PublicRecordList({
|
||||
records,
|
||||
@@ -22,7 +23,7 @@ export function PublicRecordList({
|
||||
<span className="record-kind">{DOCUMENT_KIND_LABELS[record.kind]}</span>
|
||||
<div>
|
||||
<strong>{record.title}</strong>
|
||||
<p>{record.summary}</p>
|
||||
<p>{cardSummary(record.summary)}</p>
|
||||
<span className="record-context">
|
||||
{record.topic} · {record.projectTitle}
|
||||
</span>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Link } from "react-router-dom";
|
||||
|
||||
import { usePublicContent } from "../use-public-content.tsx";
|
||||
import { HighlightMatch } from "../../shared/highlight-match.tsx";
|
||||
import { cardSummary } from "../../shared/card-summary.ts";
|
||||
|
||||
type SearchDialogProps = {
|
||||
className?: string;
|
||||
@@ -110,7 +111,7 @@ export function SearchDialog({
|
||||
<HighlightMatch text={entry.title} query={query} />
|
||||
</strong>
|
||||
<p>
|
||||
<HighlightMatch text={entry.summary} query={query} />
|
||||
<HighlightMatch text={cardSummary(entry.summary)} query={query} />
|
||||
</p>
|
||||
</Link>
|
||||
</li>
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* 목록·검색 카드에 실을 요약을 평문으로 만든다.
|
||||
*
|
||||
* <p>카드는 본문 요약을 그대로 가져다 세 줄로 자른다. 그 요약은 Markdown 으로 쓰였으므로
|
||||
* 작성자가 코드 표시로 쓴 백틱이 카드에도 그대로 나왔다 — 문서 본문에서는 `<code>` 가 되지만
|
||||
* 카드에서는 그냥 문자다. 홈·탐색·검색이 같은 텍스트를 쓰므로 세 곳에서 같이 보였다.
|
||||
*
|
||||
* <p>카드에서 코드 스타일을 살리지 않는 이유는 카드가 훑어보는 자리이기 때문이다. 한 줄 안에
|
||||
* 배경색 조각이 여럿 끼면 제목보다 그쪽이 먼저 눈에 든다. 문단 줄바꿈도 공백으로 접는다 —
|
||||
* 어차피 세 줄에서 잘리므로 줄을 지켜 봐야 잘리는 위치만 어긋난다.
|
||||
*/
|
||||
export function cardSummary(text: string | null | undefined): string {
|
||||
if (!text) return "";
|
||||
return text.replace(/`/gu, "").replace(/\s+/gu, " ").trim();
|
||||
}
|
||||
@@ -36,3 +36,27 @@ describe("검색어 강조", () => {
|
||||
expect(container.querySelectorAll("mark")).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 목록·검색 카드는 본문 요약을 그대로 가져다 세 줄로 자른다. 그 요약은 Markdown 이므로
|
||||
* 작성자가 코드 표시로 쓴 백틱이 카드에도 그대로 나왔다 — 홈·탐색·검색이 같은 텍스트를 쓰므로
|
||||
* 세 곳에서 같이 보였다.
|
||||
*/
|
||||
describe("카드 요약", () => {
|
||||
it("백틱을 지우고 줄바꿈을 접는다", async () => {
|
||||
const { cardSummary } = await import(
|
||||
"../../src/features/tech-log/presentation/shared/card-summary.ts"
|
||||
);
|
||||
expect(cardSummary("모두 하나의 `로그인 상태`로 보면\n안 된다.\n\n두 번째 문단.")).toBe(
|
||||
"모두 하나의 로그인 상태로 보면 안 된다. 두 번째 문단.",
|
||||
);
|
||||
});
|
||||
|
||||
it("빈 값이면 빈 문자열을 준다", async () => {
|
||||
const { cardSummary } = await import(
|
||||
"../../src/features/tech-log/presentation/shared/card-summary.ts"
|
||||
);
|
||||
expect(cardSummary(undefined)).toBe("");
|
||||
expect(cardSummary(" ")).toBe("");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user